ddply aggregated column names

Viewed 3569

I am using ddply to aggregate my data but haven't found an elegant way to assign column names to the output data frame.

At the moment I am doing this:

agg_data <- ddply(raw_data, .(id, date, classification), nrow)
names(agg_data)[4] <- "no_entries"

and this

agg_data <- ddply(agg_data, .(classification, date), colwise(mean, .(no_entries)) )
names(agg_data)[3] <- "avg_no_entries"

Is there a better, more elegant way to do this?

2 Answers
Related