[R] Using a string as a filter

Yzhar Toren torenizh at post.tau.ac.il
Sun Jul 10 15:24:32 CEST 2005

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.

More information about the R-help mailing list