Skip to content
Prev 274842 / 398506 Next

converting string fractions to numerics

Here is another possibility:
[1] "pi/2" "1/2"
+ function(x) {
+ x <- ifelse(x=="pi",pi,x)
+ as.numeric(x[1])/as.numeric(x[2])
+ }
+ )
[1] 1.570796 0.500000
Thanks for everyone's help!

Sincerely,
Erin
On Wed, Oct 19, 2011 at 2:06 AM, Rolf Turner <rolf.turner at xtra.co.nz> wrote: