hadley/reshape — Issue #11: problems with some aggregation functions (min, max, median)
Author: timhandley
Created: 2011-12-14 19:57:52+00:00
State: open

I've come across some unexpected problems with reshape 2. In short, some choices for fun.aggregate cause warnings or errors. Use of either min or max produces a warning, though dcast still gives the right result. Using median produces an error, and no results at all. The following short bit of code illustrates this point:

library(reshape2)
testdata = data.frame(type=rep(c("a","b"),10), value=1:20)
dcast(testdata, type~. , fun.aggregate=mean)
dcast(testdata, type~. , fun.aggregate=sum)
dcast(testdata, type~. , fun.aggregate=min)
dcast(testdata, type~. , fun.aggregate=max)
dcast(testdata, type~. , fun.aggregate=median)