Re: [R] Subset in cast: compact form?

From: hadley wickham <h.wickham_at_gmail.com>
Date: Thu, 12 Jun 2008 15:21:59 -0500

On Thu, Jun 12, 2008 at 2:27 PM, Agustin Lobo <aloboaleu_at_gmail.com> wrote:
> Hi!
>
> How can I subset several variables in cast?
>
> For example, I can do it for one, (ie, ph):
> cast(am, organismo +arriba ~ variable,subset=variable=="ph",mean,na.rm=T)
>
> For selecting ph, temperature and Ba I'm using:
> cast(am, organismo +arriba ~ variable,subset=variable=="ph"
> variable=="temperature"| variable== "Ba",mean,na.rm=T)

Probably the most compact way is:

cast(am, organismo +arriba ~ variable ,
 subset =variable %in% c("ph", "temperature","Ba") ,  mean, na.rm=T
)

(that's an R thing, not particular to reshape)

Hadley

-- 
http://had.co.nz/

______________________________________________
R-help_at_r-project.org 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 Thu 12 Jun 2008 - 22:14:51 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 Thu 12 Jun 2008 - 22:30:48 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.

list of date sections of archive