Thanks Baptiste
The eval(parse()) combination is just what I need.
baptiste auguie wrote:
Try this,
mystr <-"c==1"
subset(foo, eval(parse(text = mystr)) )
library(fortunes)
fortune("parse") # try several times
# I prefer this, but there is probably a better way
mycond<- quote(c==1)
subset(fo
That's right, however the bquote construct may be useful when
combining several conditions,
subset(foo, eval(bquote(.(mycond) & a < 5)) )
baptiste
2009/8/22 Vitalie S. :
> On Fri, 21 Aug 2009 22:38:09 +0200, baptiste auguie
> wrote:
>
>> Try this,
>>
>> mystr <-"c==1"
>> subset(foo, eval(parse(
On Fri, 21 Aug 2009 22:38:09 +0200, baptiste auguie
wrote:
Try this,
mystr <-"c==1"
subset(foo, eval(parse(text = mystr)) )
library(fortunes)
fortune("parse") # try several times
# I prefer this, but there is probably a better way
mycond<- quote(c==1)
subset(foo, eval(bquote(.(mycond))) )
Sebastien,
My understanding is the argument of c==1 in subset() is actually to evaluate
foo$c==1, which returns a vector of logical values. Try this,
mystr<-foo$c==1
subset(foo,mystr)
Jun
On Fri, Aug 21, 2009 at 3:21 PM, Sebastien Bihorel <
sebastien.biho...@cognigencorp.com> wrote:
> Dear R-u
Try this,
mystr <-"c==1"
subset(foo, eval(parse(text = mystr)) )
library(fortunes)
fortune("parse") # try several times
# I prefer this, but there is probably a better way
mycond<- quote(c==1)
subset(foo, eval(bquote(.(mycond))) )
HTH,
baptiste
2009/8/21 Sebastien Bihorel :
> Dear R-users,
>
Dear R-users,
The following question bothered me for the whole afternoon: how can one
pass a string as the conditioning argument to subset? I tried plain
mystr, eval(mystr), expression(mystr), etc... I don't to be able to find
the correct syntax
> foo <- data.frame(a=1:10,b=10:1,c=rep(1:2,5)
6 matches
Mail list logo