Re: [R] question on 'within' and 'parse' commands

2010-01-07 Thread Romain Francois
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") 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

[R] question on 'within' and 'parse' commands

2010-01-07 Thread N Klepeis
Hi, Why can't I pass an expression to `within' by way of textual input to the 'parse' function? e.g., > x <- data.frame(a=1:5,b=LETTERS[1:5]) > x a b 1 1 A 2 2 B 3 3 C 4 4 D 5 5 E > within(x, parse(text="a<-a*10; b<-2:6")) a b 1 1 A 2 2 B 3 3 C 4 4 D 5 5 E > within(x, parse(text="a<-a*10; b