Aggregate rows by shared values in a variable
I have a somewhat dumb R question. If I have a matrix (or dataframe, whichever is easier to work with) like: Year Match 2008 1808 2008 137088 2008 1 2008 56846 2007 2704 2007 169876 2007 75750 2006 2639 2006 193990 2006 2 And I wanted to sum each of the match counts for the years (so, e.g. the 2008 row would be 2008 195743 , how would I go about doing this? I've got a few solutions in my head but they are all needlessly complicated and R tends to have some much easier solution tucked away somewhere. You can generate the same matrix above with: structure(c(2008L, 2008L, 2008L, 2008L, 2007L,