Re: [R] subset arg in (modified) evalq

From: Vadim Ogranovich <vogranovich_at_jumptrading.com>
Date: Fri, 18 May 2007 09:50:45 -0500 (CDT)


Thanks Gabor! This does exactly what I wanted.

One follow-up question, how to extract the var names, in this case y, z, from the expression? The subset function creates a new object and this may be expensive when the data has a lot of irrelevant collumns. So I thougth that I could reduce this to the columns I actually need.

Thanks,
Vadim

Try this:

with(subset(data, x > 0), summary(y + z))

On 5/18/07, Vadim Ogranovich <vogranovich_at_jumptrading.com> wrote:
> Hi,
>
> When using evalq to evaluate expressions within a say data.frame context I often wish there was a 'subset' argument, much like in lm() or any ather advanced regression model. I would be grateful for a tip how to do this.
>
> Here is an illustration of what I want:
>
> n <- 100
> data <- data.frame(x=rnorm(n), y=rnorm(y), z=rnorm(z))
>
> # this works
> evalq({ i <- 0<x; summary(y[i] + z[i]) }, data)
>
> # I want to do the above w/o explicit subscripting, e.g.
> myevalq(summary(y + z), subset=0<x, data)
>
> Thanks,
> Vadim
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_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
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]



R-help_at_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 and provide commented, minimal, self-contained, reproducible code. Received on Fri 18 May 2007 - 14:59:48 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 18 May 2007 - 16:30:57 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.