[R] Header of dataframe
Gregor Gorjanc
gregor.gorjanc at bfro.uni-lj.si
Fri Oct 27 07:08:53 CEST 2006
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
More information about the R-help
mailing list