Reproducible Research: Export Regression Table to MS Word

[This article was first published on theBioBucket*, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Here’s a quick tip for anyone wishing to export results, say a regression table, from R to MS Word:


require(R2wd)

# install packages required
# install software RCOM, RDCOMClient 
# (I had to restart the R-Session after the above step to get it work)

wdGet()

# Regression:
data(iris)
mod <- lm(Sepal.Length ~ Species, data = iris)
regr_tab <- data.frame(summary(mod)$coefficients)
colnames(regr_tab) <- colnames(summary(mod)$coefficients)
regr_tab[ ,4] <- ifelse(regr_tab[ ,4] < .001, "< 0.001", 
                        ifelse(regr_tab[ ,4] < .01, "< 0.01", 
                        round(regr_tab[ ,4], 3)))

# print table to doc in word-default format:
wdTable(format(regr_tab), autoformat = 1)

wdSave("Regression.doc")     # save file 
wdQuit()                     # close file

ps: Also check odfWeave
- this also seems to be a very useful resource!

To leave a comment for the author, please follow the link and comment on their blog: theBioBucket*.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)