[R] convert a Character-string to a number
Simon Fear
Simon.Fear at synequanon.com
Fri Sep 12 14:40:38 CEST 2003
as.numeric(gsub(",", ".", a))
works if the locale is such that decimal points are used instead of
commas, but you might seek a more generic solution and have
R use a comma for decimal separation - see ?localeconv.
> -----Original Message-----
> From: Michael Kirschbaum [mailto:emkiba at gmx.de]
> Sent: 12 September 2003 13:29
> To: R-Help
> Subject: [R] convert a Character-string to a number
>
>
> Security Warning:
> If you are not sure an attachment is safe to open please contact
> Andy on x234. There are 0 attachments with this message.
> ________________________________________________________________
>
> 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
>
> M.Kirschbaum
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
Simon Fear
Senior Statistician
Syne qua non Ltd
Tel: +44 (0) 1379 644449
Fax: +44 (0) 1379 644445
email: Simon.Fear at synequanon.com
web: http://www.synequanon.com
Number of attachments included with this message: 0
This message (and any associated files) is confidential and\...{{dropped}}
More information about the R-help
mailing list