try this: scores.melt = data.frame(grade = floor(runif(100, 1,10)), variable = 'score', value = rnorm(100));
cast(scores.melt, grade ~ variable, fun.aggregate = c(mean, length)) it has the nice column names of: grade score_mean score_length 1 1 0.08788535 8 2 2 0.16720313 15 3 3 0.41046299 7 4 4 0.13928356 13 ... but now try this: cast(scores.melt, grade ~ variable, fun.aggregate = c(mean, function(x) sum(x < 0))) and you get a huge mess: grade score_mean score_function.x..sum.x...0. 1 1 0.08788535 4 2 2 0.16720313 6 3 3 0.41046299 2 4 4 0.13928356 5 I would think that something like this would fix it up, but no dice: cast(scores.melt, grade ~ variable, fun.aggregate = c(mean, num.neg = function(x) sum(x < 0))) that is, why not look at names(fun.aggregate)? or am I missing something? thanks, Mike I would think that -- View this message in context: http://www.nabble.com/resultant-column-names-from-reshape%3A%3Acast%2C-with-a-fun.aggregate-vector-tp17910885p17910885.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.