Skip to content
Back to formatted view

Raw Message

Message-ID: <AD526A31-64AB-4C17-AE03-F39603D96168@gmail.com>
Date: 2011-10-19T06:54:37Z
From: michael.weylandt at gmail.com (R. Michael Weylandt
Subject: converting string fractions to numerics
In-Reply-To: <CACxE24n9=gRXo1kVhjG_63x+LtDE5KEEnJc96JJ3i8Dthjr3Mw@mail.gmail.com>

I would imagine that you could parse+evaluate it like you asked about on another thread; this isn't tested though. Does that work in your context?

Michael Weylandt

On Oct 19, 2011, at 2:30 AM, 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.