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

From: hadley wickham <>
Date: Tue, 17 Jun 2008 09:49:54 -0500

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



______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 17 Jun 2008 - 15:45:56 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 17 Jun 2008 - 16:30:41 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive