This question is about column names returned by the aggregate function. 
Consider the following example

df <- data.frame(
   id = c(rep('11',30),rep('22',30),rep('33',30)),
   value = c(rnorm(30,2,0.5), rnorm(30,3,0.5), rnorm(30,6,0.5))
)

aggregate(df[,c("value"),drop=FALSE], by=list(id=df$id), max)
output:
  id    value
1 11 2.693528
2 22 3.868400
3 33 6.942519

aggregate(df$value, by=list(id=df$id), max)
output:
  id        x
1 11 2.693528
2 22 3.868400
3 33 6.942519

(YMMV on output values since data is randomly generated)

I would like to be able to name the output column as max.value.  I realize I 
can add the following statement:
colnames(df)[match("value",colnames(df))] <- "max.value"

Is there a way of having aggregate return computed column names which can be 
specified when calling the function (i.e. aggregate)?

______________________________________________
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.

Reply via email to