I have some data for example c("1k", "2k", "1.5k" ...), and would like tp transform the ks to c("1000", "2000", "1500", ...), gsub is quite fast in replacing a large list, but it wouldn't be able to match the 1 or 1.5 and then multiply 1000.
I could match (\d+(.\d{1})?[Kk]), (\d+(.\d{2})?[Kk]), (\d+(.\d{3})?[Kk]) and replace them, but it looks like a brute force approach so I would like to see is there any other ways I can quickly extra the number and then do the calculation?
I tried extracted the number and then multiplied them and then loop through the list and did a gsub individually but it is very slow.
Thanks a lot.
Note that the strings can be ' 1k', 'display price: 1k', '1k - 2k' and some other random characters etc. We always want to get the first price appears so for the 1k - 2k case we want to get 1k.
And also there are millions of rows so performance could gets worse when the substitution is being done several times.