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

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

On Thu, Jun 12, 2008 at 2:27 PM, Agustin Lobo <> 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)



______________________________________________ mailing list
PLEASE do read the posting guide
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 Please read the posting guide before posting to the list.

list of date sections of archive