[R] Converting Character Strings to Numerical Values

Sarah Goslee sarah.goslee at gmail.com
Mon Nov 13 22:40:41 CET 2006


?as.numeric

> x <- "3"
> y <- "3.5"

> x
[1] "3"
> as.numeric(x)
[1] 3

> y
[1] "3.5"
> as.numeric(y)
[1] 3.5

Sarah

On 11/13/06, Peter Lauren <peterdlauren at yahoo.com> wrote:
> Does R have anything like strtod, atoi, atod, etc. in
> C?  I would like to covert "3" to 3 and "3.5" to 3.5 .
>
> Thanks,
> Peter Lauren.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list