Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@WhiteChair WhiteChair commented Jan 12, 2018

image

any idea what the error means?

@amarder

This comment has been minimized.

Copy link

@amarder 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
You can’t perform that action at this time.