[R] Summing rows by years (each time separately)

David Winsemius dwinsemius at comcast.net
Mon Jan 9 15:33:53 CET 2012


On Jan 9, 2012, at 9:06 AM, Andrew Gaska wrote:

> Thanks for your answer!
>
> There is one thing I could not find in aggregate():
>
> I want to have it a sum for each group of 2008,2009 and 2010. In
> aggregate() I can sum all the rows that have a rowname 2008,  all  
> the rows
> that have a rowname 2009 and all the rows that have a rowname 2010.
>
> But I want to have it summed separately each time a new group  
> starts, so not
> like this:
>
> 2008 24 20 16
> 2009 19 12 17
> 2010 16 19 13
>
> but like this:
>
> 2008        15	12	10
> 2009        9	3	7
> 2010        10	14	10
> 2008        9	8	6
> 2009        10	9	10
> 2010        6	5	3
>

You appear to be changing your request. If you want an unambiguous  
anser submit an unambiguous dataset. Use dput() on hte datafame or  
matrix and then we can all be on the same page.

>
> --
> View this message   blah blah
> Sent from the R help mailing list archive at Nabble.com.

We are not reading this on Nabble. Include context.

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list