[R] tapply on multiple groups

David Winsemius dwinsemius at comcast.net
Thu Jan 28 17:49:35 CET 2010


On Jan 28, 2010, at 10:26 AM, GL wrote:

>
> Can you make tapply break down groups similar to bwplot or such?  
> Example:
>
> Data frame has one measure (Days) and two Dimensions (YYYYMM and  
> Place). All
> have the same length.
>
>> length(dbs.final$Days)
> [1] 3306
>> length()
> [1] 3306
>> length()
> [1] 3306
>
> Doing the following makes a nice table for one dimension and one  
> measure:
>
>    do.call(rbind,tapply(dbs.final$Days,dbs.final$Place, summary))
>
> But, what I really need to do is break it down on two dimensions and  
> one
> measures - effectively equivalent to the following bwplot call:
>
>    bwplot( Days ~ YYYYMM | Place, ,data=dbs.final)
>
> Is there an equivalent to the "|" operation in tapply?

Please reread the help page for tapply.

Perhaps?:

tapply(dbs.final$Days, list(dbs.final$YYYYMM, dbs.final$Place) summary)

-- David

>
> -- 
> View this message in context: http://n4.nabble.com/tapply-on-multiple-groups-tp1380593p1380593.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT



More information about the R-help mailing list