-1

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

Sven Hohenstein
  • 80,497
  • 17
  • 145
  • 168
  • 1
    Duplicate Question https://stackoverflow.com/questions/4931545/converting-string-to-numeric – Kyoujin Dec 24 '18 at 16:42
  • It's not quite a duplicate, as the question here seems to involve converting strings that include non numeric characters. – anotherfred Dec 24 '18 at 16:55

1 Answers1

0

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.

Sven Hohenstein
  • 80,497
  • 17
  • 145
  • 168