[R] Two-way/Three-way sum.
Greg Snow
Greg.Snow at imail.org
Thu Dec 3 19:55:59 CET 2009
?tapply
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Peng Cai
> Sent: Thursday, December 03, 2009 11:50 AM
> To: r-help at r-project.org
> Subject: [R] Two-way/Three-way sum.
>
> Hi R Users,
>
> I'm wondering how can I calculate two (or three) way sum of a variable.
> A
> sample data is:
>
> State Month Year Value
> NC Jan 1996 1
> NC Jan 1996 2
> NC Feb 1997 2
> NC Feb 1997 3
> NC Mar 1998 3
> NC Mar 1998 4
> NY Jan 1996 4
> NY Jan 1996 5
> NY Feb 1997 5
> NY Feb 1997 6
> NY Mar 1998 6
> NY Mar 1998 7
>
> I'm trying to sum up "value" column by State*Month and by
> State*Month*Year.
> Also, I may need to calculate mean value along with "sum".
>
> Any help would be greatly appreciated,
>
> Thanks,
> Peng
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
More information about the R-help
mailing list