[R] re sultant column names from reshape::cast, with a fun.aggregate vector

hadley wickham h.wickham at gmail.com
Tue Jun 17 16:49:54 CEST 2008


> 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?

Yes, that's a bug in each (the function which turns a vector of
functions into a function that returns a named vector of outputs).
I've added a note to my to do.  In the meantime, you can do:

num.neg <- function(x) sum(x < 0)
cast(scores.melt, grade ~ variable, fun.aggregate = c(mean, num.neg))

Hadley


-- 
http://had.co.nz/



More information about the R-help mailing list