Reproducible Research: Export Regression Table to MS Word

April 20, 2012
By

(This article was first published on theBioBucket*, and kindly contributed to R-bloggers)

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 his blog: theBioBucket*.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.