[R] basic statistics to csv
a.ramasamy at imperial.ac.uk
Tue Oct 27 09:53:27 CET 2009
It would be useful to have a simplified version of the 'nsu' object.
I am guessing it is a list of some sort (e.g. mean is single value,
quantiles here returns 5 numbers) and not a matrix or dataframe (i.e.
regular array). So you can have several choices here:
1) print nsu to a file. e.g. cat(nsu, file="lala", append=T) or using
the sequence sink(file="lala"); print(nsu); sink()
2) compile the nsu objects into a list (if generating nsu takes time,
you can save each nsu and then have a script to read them all into a
list). Then extract the means across the elements in the list (e.g.
sapply) and compile into a regular array before using csv.
lanczos at fns.uniba.sk wrote:
> I know that my question is like a very newbie question, but at the moment
> I stacked with it and I need a quick solution. I need to make an overall
> statistical overview of various datasets, the summary() and numSummary()
> functions are fully sufficient. My question is, how can I export results
> to a spreadsheet-like file, as a .csv. For the summary() with an "x"
> dataset I can use this way:
> su <- summary(x)
> write.csv(su, file = "summary.csv")
> The problem with this is that the csv file is rather chaotic.
> but when I apply the same for the numSummary(x) output like:
> nsu <- numSummary(x[,c("a", "b", "c")], statistics=c("mean", "sd",
> "quantiles"), quantiles=c(0,.25,.5,.75,1))
> write.csv(nsu, file = "numsummary.csv")
> I get the "ERROR: cannot coerce class "numSummary" into a data.frame"
> Is there a more convenient way to get a spreadsheet-like output for the
> basic statistics?
> Many thanks for any help
> R-help at r-project.org mailing list
> 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