[R] output by(...)

Skála, Zdeněk (INCOMA GfK) Zdenek.Skala at gfk.com
Sun Mar 25 11:55:35 CEST 2012


Dear all,

I have a question that is probably pretty stupid, so apologies in advance...

I do a simple

> mydata.tab <- by(my.data.frame, my.data.frame$category, colMeans)

...works fine, but I need to output the results to some "flat" file (kind of table) to work with it in Excel etc.

So I am doing now

> capture.output(data.frame(unlist(mydata.tab)), file="mydata.txt")

...and process the result in Excel.
Do you know a more pretty way to do this task? Perhaps something other than 'by()' to make a table of colMeans?

Many thanks!
Zdenek



More information about the R-help mailing list