Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

We often use logistic regression models in our analyses and we also often need to publish the results in table format. And, we always use MS Word since this is our standard office in our department. So I thought about an easy way of how to transfer the results of fitted generalized linear models from R to Word. An appropriate way – for me – is to create HTML tables, simply open them in Word and copy’n’paste them into my document. This works much better than all things I have tried with SPSS tables (if someone has an easier solution, let me know!).

I wrote a little script called sjTabOdds.R, which can be downloaded here. This script requires one or more glm-objects, the destination file path and the labels of predictor and dependent variables as parameters. Here are some examples of different table styles…

First, load the script, compute two fitted models and create labels:

source("sjTabOdds.R")
y1 <- ifelse(swiss\$Fertility
Now, generate the tables:
sjt.glm(fitOR1, fitOR2,
labelDependentVariables=labdep,
labelPredictors=lab,
file="or_table1.html")
Default table style
sjt.glm(fitOR1, fitOR2,
labelDependentVariables=labdep,
labelPredictors=lab,
file="or_table2.html",
pvaluesAsNumbers=T)
Table with p-values as numbers
sjt.glm(fitOR1, fitOR2,
labelDependentVariables=labdep,
labelPredictors=lab,
file="or_table3.html",
separateConfColumn=T)
Table with separated column for CI
sjt.glm(fitOR1, fitOR2,
labelDependentVariables=labdep,
labelPredictors=lab,
file="or_table4.html",
pvaluesAsNumbers=T,
separateConfColumn=T)
Table with p-values as numbers and separated column for CI
These html-files can be opened with word and the shown table can be copied’n'pasted into your own document.
Tagged: R, rstats, Statistik

var vglnk = {key: '949efb41171ac6ec1bf7f206d57e90b8'};
(function(d, t) {
var s = d.createElement(t);
s.type = 'text/javascript';
s.async = true;
// s.defer = true;
var r = d.getElementsByTagName(t)[0];
r.parentNode.insertBefore(s, r);
}(document, 'script'));

Related
ShareTweet