I am new to R. I am working on a dataset which is a large list, there is a column with numbers and strings. I want to remove the string and convert to numeric.
I have 100,000+
I want 100,000 and numeric
I am new to R. I am working on a dataset which is a large list, there is a column with numbers and strings. I want to remove the string and convert to numeric.
I have 100,000+
I want 100,000 and numeric
You can use gsub
to transform the string:
as.numeric(gsub("[^0-9.]", "", "100,000+"))
# [1] 1e+05
Here, all characters, except digits and .
, are removed before applying as.numeric
.