Re: [R] dynamically extract data from a list

2008-08-12 Thread Gabor Grothendieck
> eval(parse(text = "iris[iris$Sepal.Width > 4,]")) Sepal.Length Sepal.Width Petal.Length Petal.Width Species 16 5.7 4.4 1.5 0.4 setosa 33 5.2 4.1 1.5 0.1 setosa 34 5.5 4.2 1.4 0.2 setosa >

Re: [R] dynamically extract data from a list

2008-08-12 Thread Gabor Grothendieck
The code I posted does work if you use it as I explained, not as you changed it. Executing strings is probably not a very R-ish thing to do but if that's your aim use eval and parse: s <- "iris["iris$Sepal.Width > 4,]" eval(parse(text = s)) On Tue, Aug 12, 2008 at 10:35 AM, Dries Knapen <[EMAIL

Re: [R] dynamically extract data from a list

2008-08-12 Thread Dan Davison
Dries Knapen-2 wrote: > > Hi, > > Thanks for your reply. However, this didn't work exactly as I needed > it to since the expression is dynamically built as a character vector > > i.e. not executed as > e <- expression(Sepal.Width > 4) > > but as > e <- expression("Sepal.Width > 4") > > in

Re: [R] dynamically extract data from a list

2008-08-12 Thread Dries Knapen
On 12 Aug 2008, at 17:00, Gabor Grothendieck wrote: Executing strings is probably not a very R-ish thing to do I know - but as far as I can see there was no other way around in this case... but if that's your aim use eval and parse: s <- "iris["iris$Sepal.Width > 4,]" eval(parse(text = s

Re: [R] dynamically extract data from a list

2008-08-12 Thread Dries Knapen
Hi, Thanks for your reply. However, this didn't work exactly as I needed it to since the expression is dynamically built as a character vector i.e. not executed as e <- expression(Sepal.Width > 4) but as e <- expression("Sepal.Width > 4") in which case subset() throws an error (must evaluat

Re: [R] dynamically extract data from a list

2008-08-11 Thread Gabor Grothendieck
Try this: > e <- expression(Sepal.Width > 4) > subset(iris, eval(e), select = "Sepal.Length") Sepal.Length 16 5.7 33 5.2 34 5.5 > subset(iris, eval(e)) Sepal.Length Sepal.Width Petal.Length Petal.Width Species 16 5.7 4.4 1.5 0.4 s

[R] dynamically extract data from a list

2008-08-11 Thread Dries Knapen
Hi, Based on user input, I wrote a function that creates a list which looks like: > str(list) List of 4 $ varieties: chr [1:12] "temp.26_time.5dagen_biorep.1" "time. 5dagen_temp.26_biorep.2" "temp.18_time.5dagen_biorep.1" "temp.18_time. 5dagen_biorep.2" ... $ temp : Factor w/ 2 level