Trying to report regression tables in Word format using rmarkdown seems impossible. After trying hours and several options like here no one worked in my case. I want to report lm
models using markdown and render to a .doc file.
Method 1:
Using memisc
package to create a mtable
object and render using pander
:
> lm0 <- lm(hp ~ wt, mtcars)
> lm1 <- lm(qsec ~ hp, mtcars)
> lm2 <- lm(qsec ~ wt, mtcars)
>
> library(memisc)
>
> mt <- mtable(lm0, lm1, lm2)
>
> pander::pander(mt)
Error in x[[i]] : subíndice fuera de los límites
Además: Warning message:
In pander.default(mt) :
No pander.method for "memisc_mtable", reverting to default.
Method 2:
Create a html object and include using includeHTML
. So far this is the closed method to my desire output. However the table only contains one column like this:
```{r}
stargazer::stargazer(lm0, lm1, lm2, type = "html", title = "Results", out = "./pp.html")
shiny::includeHTML("pp.html")
```
Code above produces this in a word document:
Method 3:
Using xtable
also produces the same output above.
Any suggestions?