I have data like the following two (in different columns) in character format and I want to be able to change them to numbers. I try with the formula as.numeric
applying an gsub
internal to replace the comma or point depending on the case, but I always end up with all NA values. Thanks in advance.
Volume | Cash |
---|---|
14,262,212 | 134,430.40 |
It seems that in your case the
,
is the decimal separator and the.
thousands separator, in order to convert this data you would have to (a) remove the dots (b) replace the comma with a dot. For example, you can usegsub()
to do the replacements:In your case you could do something like this: