Benjamin Dickgiesser <dickgiesser <at> gmail.com> writes:
...
> Is there an easy way to add a column name to the first column?
What about
summary.aggregate <- function(y, ...)
{
temp.mean <- aggregate(y, FUN=mean, ...)
temp.sd <- aggregate(y, FUN=sd, ...)
temp.length <- aggregate(y, FUN=length, ...)
temp <- data.frame(cbind(col=names(y), mean=temp.mean$x,
stdev=temp.sd$x,n=temp.length$x))
}
or
summary.aggregate <- function(y, ...)
{
temp.mean <- aggregate(y, FUN=mean, ...)
temp.sd <- aggregate(y, FUN=sd, ...)
temp.length <- aggregate(y, FUN=length, ...)
temp <- data.frame(cbind(mean=temp.mean$x,
stdev=temp.sd$x,n=temp.length$x))
rownames(temp) <- names(y)
}
Gregor
______________________________________________
[email protected] 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.