Skip to content

Instantly share code, notes, and snippets.

@daroczig
Last active January 24, 2018 19:22
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daroczig/84d44ea5d944da6e4c44e1d1c6cba784 to your computer and use it in GitHub Desktop.
Save daroczig/84d44ea5d944da6e4c44e1d1c6cba784 to your computer and use it in GitHub Desktop.
Multiple regression models in a markdown table with memisc and pander
m1 <- lm(mpg ~ hp, data = mtcars)
m2 <- lm(mpg ~ hp + drat, data = mtcars)
m3 <- lm(mpg ~ hp + drat + factor(gear), data = mtcars)
library(pander); library(memisc)
panderOptions('table.alignment.rownames', 'left')
pander(relabel(
mtable(m1, m2, m3,
summary.stats=c('N', 'R-squared', 'F')),
'(Intercept)' = 'Constant',
'hp' = 'Gross horsepower',
'factor(gear): 4/3' = 'Four forward gears',
'factor(gear): 5/3' = 'Five forward gears',
'N' = 'Observations'))
------------------------------------------------------------------
&nbsp; m1 m2 m3
------------------------ ------------- ------------- -------------
**Constant** 30.099***\ 10.790*\ 16.306*\
(1.634) (5.078) (6.429)
**Gross horsepower** -0.068***\ -0.052***\ -0.064***\
(0.010) (0.009) (0.011)
**drat** \ 4.698***\ 3.510\
(1.192) (1.851)
**Four forward gears** \ \ -0.276\
(2.135)
**Five forward gears** \ \ 3.761\
(2.161)
**Observations** 32 32 32
**R-squared** 0.6 0.7 0.8
**F** 45.5 41.5 24.2
------------------------------------------------------------------
@WhiteChair
Copy link

image

any idea what the error means?

@amarder
Copy link

amarder commented Jan 24, 2018

"the most recent version of the pander package dropped support for mtable but there are plans to re-integrate it at Rapporter/pander#304"

https://stackoverflow.com/questions/24342162/regression-tables-in-markdown-format-for-flexible-use-in-r-markdown-v2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment