[R] Using a string as a filter

From: Yzhar Toren <torenizh_at_post.tau.ac.il>
Date: Sun 10 Jul 2005 - 23:24:32 EST

Hi ,

I want to be able to filter out results using a string. I'm running an automated script that reads a list of filters I get from an external source and applys them to my data frame consecutively.

For example I want to get : data[protocol==1], data[protocol==2] ...

If I define
filter1 <- "protocol==1" (as a string)
filter2 <- "protocol==2"
How can I use these variables to choose subsets ?

I managed to find a very awkward method by using a function that calls a formula (and using as.formula() for the string I want to get), but I would love to find a more efficient way

Thank you !
Yzhar Toren, Tel-Aviv university.

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sun Jul 10 22:32:24 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:27 EST