Re: [R] Using a string as a filter

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Sun 10 Jul 2005 - 22:49:42 EST

On 7/10/05, Yzhar Toren <torenizh@post.tau.ac.il> wrote:
> 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"
> ...

protocol <- 1:5
data <- 11:15
filter <- "protocol==1"
data[eval(parse(text=filter))] # 11



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:54:36 2005

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