Re: [R] aggregate(), tapply(): Why is the order of the grouping variables not kept?

2013-03-12 Thread Marius Hofert
I'm no expeRt, but suppose that we change the setup slightly: xx - x[sample(nrow(x)), ] Now what would you like aggregate(value ~ group + year, data=xx, FUN=function(z) z[1]) to return? Personally, I prefer to have R return the same thing regardless of how the input dataframe is

[R] aggregate(), tapply(): Why is the order of the grouping variables not kept?

2013-03-11 Thread Marius Hofert
Dear expeRts, The question is rather simple: Why does aggregate (or similarly tapply()) not keep the order of the grouping variable(s)? Here is an example: x - data.frame(group = rep(LETTERS[1:2], each=10), year = rep(rep(2001:2005, each=2), 2), value =

Re: [R] aggregate(), tapply(): Why is the order of the grouping variables not kept?

2013-03-11 Thread Peter Ehlers
On 2013-03-11 13:52, Marius Hofert wrote: Dear expeRts, The question is rather simple: Why does aggregate (or similarly tapply()) not keep the order of the grouping variable(s)? Here is an example: x - data.frame(group = rep(LETTERS[1:2], each=10), year = rep(rep(2001:2005,