[R] converting string fractions to numerics
baptiste auguie
baptiste.auguie at googlemail.com
Wed Oct 19 08:57:39 CEST 2011
Hi,
I believe you want
eval(parse(text="pi/2"))
a word of warning exemplified in
eval(parse(text="library(fortunes) ; fortune(106)"))
HTH,
baptiste
On 19 October 2011 19:30, Erin Hodgess <erinm.hodgess at gmail.com> wrote:
> Dear R People:
>
> Suppose I have the following:
>
> "pi/2"
>
> and I would like it to be 1.57.....
>
> Using as.numeric, here is my result:
>
>> as.numeric("pi/2")
> [1] NA
> Warning message:
> NAs introduced by coercion
>>
>
> Is there a way to produce the numeric result, please?
>
> Thanks,
> Erin
>
>
> --
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: erinm.hodgess at gmail.com
>
> ______________________________________________
> R-help at r-project.org 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.
>
More information about the R-help
mailing list