Skip to content

Replacing a period in a string

3 messages · Luis Felipe Parra, David Winsemius, Earl F. Glynn

#
On Dec 2, 2010, at 10:46 PM, Luis Felipe Parra wrote:

            
If that is in a file then read.csv2 is the answer.

If it is in a string within the R environment, then perhaps  
read.csv2(file=textConnection(robject_name))

Please do read the Posting Guide and post reproducible examples (or at  
least unambiguous descriptions of the problem).

David Winsemius, MD
West Hartford, CT
#
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: