I like using R for statistical analysis but find it difficult to compare output of different models.
Is there any way, we can export output to excel to make it more readable (using some formatting like scientific to number notation, conditional formatting etc)?
As suggested by @42 How to Copy Summary() output from R to Excel, I tried capture.output() but it doesn't work properly. I've searched a lot, couldn't find a solution.
Using the package XLConnect
you can write R output to Excel files.
Here's an example, where I write a model and send the summary to excel:
library(XLConnect)
dat <- data.frame(rsp = rnorm(100, 0, 1),
pred1 = rnorm(100, 0, 1),
pred2 = rnorm(100, 0, 1))
model <- lm(rsp ~ pred1 + pred2, data = dat)
writeWorksheetToFile("model1.xlsx",
data = summary(dat),
sheet = "summary",
header = TRUE,
clearSheets = TRUE)
If you are trying to export the output of summary
function, try this
write.csv(summary(data_frame),"output.csv")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With