[R] Formula Interpreter in R

Gabor Grothendieck ggrothendieck at gmail.com
Fri Jun 3 18:28:34 CEST 2011


On Fri, Jun 3, 2011 at 11:48 AM, amit jain <buddyhi at indiatimes.com> wrote:
>
> Hi All,
> Before writing a simple formula intereter in R myself, i wanted to find out if any one has done it before. I could not locate it myself. I am looking for something like this - take a dataframe and a simple formula string as input and gives an output with formula applied on different columns of dataframe ( even better if it is time series compatibe)
>
> A crude and bad example is as below
> http://www.codeproject.com/KB/recipes/formulainterpreter.aspx
>
> I will appreciate if anyone can provide any pointers/direction
>

Try this:

fo <- "x+y/2"
eval(parse(text = fo), list(x = 1, y = 2))


-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list