cast
, from the reshape2
package, can handle a bunch of functions if passed directly in the call. For example:
library(reshape2)
d <- data.frame(variable="variable",value=rnorm(100))
cast(d, variable ~ ., c(mean,sd,max,min))
But, this doesn't work if you try to build the list of functions before hand. For example:
summary.fun <- c(mean,sd,max,min)
cast(d, variable ~., summary.fun)
I looked at the code for cast that deals with this particular behaviour and, to be honest, I have no idea what it's doing:
if (length(fun.aggregate) > 1)
fun.aggregate <- do.call(funstofun, as.list(match.call()[[4]])[-1])
Is there a way to pass a premade list of functions as a variable to cast()
?