1

How can I write several summaries to an Excel file, to have:

  1. In the first column (Min, 1st Qu, Median, Mean, 3rd Qu, Max), and in the subsequent columns only the numerical values.
  2. On the top row I need the name of the variables that I am summarizing.
  • 1
    There are many options to write to xls(x) files. See http://stackoverflow.com/questions/6099243/read-an-excel-file-directly-from-a-r-script The last hot thing is the `openxlsx` package, independent of Java. – Roman Luštrik Jul 24 '14 at 08:18

2 Answers2

2

i guess it would be something like

df<-data.frame("a"=rnorm(10), "b"=rnorm(10), "c"=rnorm(10))
output<-apply(X=df, MARGIN=2,FUN=summary)
write.table(output, file="output.csv", dec=",", sep=";")

depending on your excel version, the 'dec' and 'sep' parameters for export might vary.

agenis
  • 8,069
  • 5
  • 53
  • 102
1

You could create a data.frame with row names "Min", "1st Qu", etc. und column names of your variables and then call the usual export functions such as write.csv in base R, WriteXLS in the WriteXLS package or write.xlsx in the xlsx package. Be sure to use the row.names=TRUE argument.

Karsten W.
  • 17,826
  • 11
  • 69
  • 103