Wow.

That was fast -- and spot on!

Thanks so much.

Best Regards,

Shaun


On Aug 26, 2009, at 9:11 AM, Henrique Dallazuanna wrote:

> Try this:
>
> with(d, tapply(count, list(Date, class), sum))
>
> On Wed, Aug 26, 2009 at 10:07 AM, Shaun Grannis <sgran...@regenstrief.org 
> > wrote:
> Hi,
>
> I'm sure there's an easy approach to this issue, I'm just not seeing  
> it.
>
> I have a data frame of the following form:
>
>  Date     class    subclass   count
> 8/1/2009    A        X          1
> 8/1/2009    B        X          2
> 8/1/2009    A        Y          9
> 8/1/2009    B        Y          3
> 8/2/2009    A        X          1
> 8/2/2009    B        X          5
> 8/2/2009    A        Y          4
> 8/2/2009    B        Y          2
> 8/3/2009    A        X          6
> 8/3/2009    B        X          4
> 8/3/2009    A        Y          3
> 8/3/2009    B        Y          4
> 8/4/2009    A        X          1
> 8/4/2009    B        X          9
> 8/4/2009    A        Y          3
> 8/4/2009    B        Y          5
> 8/5/2009    A        X          3
> 8/5/2009    B        X          7
> 8/5/2009    A        Y          2
> 8/5/2009    B        Y          1
>
> I would like to create a data frame of the sum the daily counts for,
> say, class 'A', like so:
>
>
>  Date     sum_of_counts
> 8/1/2009       10
> 8/2/2009        5
> 8/3/2009        9
> 8/4/2009        4
> 8/5/2009        5
>
> I ultimately would like to do sum of counts on all classes and
> subclasses.  It seems that this is equivalent to a GROUP BY query in
> SQL.
>
> I'm sure this is possible in R. Any suggestions?
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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.
>
>
>
> -- 
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O


        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to