[R] Summary grouped by factor

Domenico Vistocco vistocco at unicas.it
Fri Mar 6 17:26:33 CET 2009


soeren.vogel at eawag.ch wrote:
> ### example:start
> v <- sample(rnorm(200), 100, replace=T)
> k <- rep.int(c("locA", "locB", "locC", "locD"), 25)
> tapply(v, k, summary)
> ### example:end
This one is better:
do.call(cbind, tapply(v,k,summary))

Ciao,
domenico
>
> ... (hopefully) produces 4 summaries of v according to k group 
> membership. How can I transform the output into a nice table with the 
> croups as columns and the interesting statistics as lines?
>
> Thx, Sören
>
> ______________________________________________
> R-help at 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.
>




More information about the R-help mailing list