[R] Subset in cast: compact form?

hadley wickham h.wickham at gmail.com
Thu Jun 12 22:21:59 CEST 2008

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)



More information about the R-help mailing list