Skip to content
Prev 243801 / 398506 Next

Replacing a period in a string

What about this?

Remove the periods and change the "," to a ".":

s <- "12.084.547,17"
x <- as.numeric(gsub(',','\\.', gsub('\\.','',s)))

options(digits=10)
x

Escaping periods is not-so-obvious.

efg

Earl F Glynn
Overland Park, KS
Luis Felipe Parra wrote: