在 Rmarkdown 中使用 apsrtable交叉发布我对多个 lm() 模型表的答案:
它可以在pdf_document
apsrtable 和 stargazer 中完成,它还支持 HTML。
---
title: "stargazer"
author: "hplieninger"
date: "3 August 2018"
output: pdf_document
header-includes:
- \usepackage{dcolumn}
---
```{r}
m1 <- lm(Fertility ~ Education , data = swiss)
m2 <- lm(Fertility ~ Education + Agriculture, data = swiss)
m3 <- lm(Fertility ~ . , data = swiss)
```
```{r, results='asis'}
apsrtable::apsrtable(m1, m2, m3, Sweave = TRUE)
```
```{r, results='asis'}
# If output: pdf_document
stargazer::stargazer(m1, m2, m3)
# If output: html_document
# stargazer::stargazer(m1, m2, m3, type = "html")
```