I have a large vector of strings of the form:
Input = c(\"1,223\", \"12,232\", \"23,0\")
etc. That\'s to say, decimals separated by commas,
The answer by adibender does not work when there are multiple commas.
In that case the suggestion from use554546 and answer from Deena can be used.
Input = c("1,223,765", "122,325,000", "23,054")
as.numeric(gsub("," ,"", Input))
ouput:
[1] 1223765 122325000 23054
The function gsub
replaces all occurances. The function sub
replaces only the first.