Displaying 1 result from an estimated 1 matches for "score_mean".
2008 Jun 17
1
re sultant column names from reshape::cast, with a fun.aggregate vector
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_...