[R] convert a Character-string to a number

Thomas Petzoldt petzoldt at rcs.urz.tu-dresden.de
Fri Sep 12 14:38:43 CEST 2003


Michael Kirschbaum schrieb:

> Hi Everyone.
> 
> I have a simple problem but don't know, how to get along.
> 
> how can I convert the vector
> 
> a<-c("0,01","1,00")
> in a vector 
> b<-c(0.01,1.00)
> 
> Thank you for suggestions

Ah, it seems to be a common German problem. My solution is:

as.numeric(sub(",",".",a))

Thomas




More information about the R-help mailing list