Skip to content
Prev 205584 / 398506 Next

question on 'within' and 'parse' commands

Hello,

parse just parse the text into an expression.

 > parse(text="a<-a*10; b<-2:6")
expression(a<-a*10, b<-2:6)
attr(,"srcfile")
<text>

If you want to evaluate the expression, you need to call eval

 > y <- within(x, eval(parse(text="a<-a*10; b<-2:6")))
 > y
    a b
1 10 2
2 20 3
3 30 4
4 40 5
5 50 6

Or you can just do this :

 > y <- within(x, { a<-a*10; b<-2:6 } )
 > y
    a b
1 10 2
2 20 3
3 30 4
4 40 5
5 50 6

Romain
On 01/07/2010 09:08 AM, N Klepeis wrote: