如何使 sjPlot::tab_model() html table 在簿记文档中编号
How to make sjPlot::tab_model() html table to be numbered in a bookdown document
我想在 bookdown 文档中添加模型中的表格(除了其他表格),以便所有表格都自动编号。使用 knitr::kable()
时效果很好。但是我无法使用模型表 sjPlot::tab_model
的第一个选项或创建这些表的其他函数来做到这一点,例如 stargazer::stargazer
和 texreg::htmlreg
这是一个简单的 .Rmd 示例:
---
title: "Example"
output: bookdown::html_document2
---
Bookdown gets numbered tables when using `kable`.
```{r tab}
knitr::kable(head(mtcars),
caption = "First table")
```
But I want to make a `tab_model` table to be also automatically numbered in the document
```{r lm-tab1}
reg_mod <- lm(mpg ~ wt, data = mtcars)
sjPlot::tab_model(reg_mod, title = "Second table")
```
Optionally, I would like to be able to do it with other package for creating automatic model
tables, such as `stargazer::stargazer`, `texreg::htmlreg` or perhaps other suggestion
```{r lm-tab2, results='asis'}
stargazer::stargazer(reg_mod, type = "html", title = "Third table")
```
```{r lm-tab3, results='asis'}
texreg::htmlreg(reg_mod, caption = "Fourth table")
```
知道如何使回归模型的 tab_model
或任何其他函数与簿记编号一起使用吗?
如 documentation 中所述,如果您在 title/caption 中包含诸如 (\#tab:my-table-lab)
之类的标签,那么 bookdown 支持自动对其他函数生成的 table 进行编号。 =14=]
例如,使用您的 tab_model
table 您可以:
reg_mod <- lm(mpg ~ wt, data = mtcars)
sjPlot::tab_model(reg_mod, title = "(\#tab:tab-model-table) Second table")
我想在 bookdown 文档中添加模型中的表格(除了其他表格),以便所有表格都自动编号。使用 knitr::kable()
时效果很好。但是我无法使用模型表 sjPlot::tab_model
的第一个选项或创建这些表的其他函数来做到这一点,例如 stargazer::stargazer
和 texreg::htmlreg
这是一个简单的 .Rmd 示例:
---
title: "Example"
output: bookdown::html_document2
---
Bookdown gets numbered tables when using `kable`.
```{r tab}
knitr::kable(head(mtcars),
caption = "First table")
```
But I want to make a `tab_model` table to be also automatically numbered in the document
```{r lm-tab1}
reg_mod <- lm(mpg ~ wt, data = mtcars)
sjPlot::tab_model(reg_mod, title = "Second table")
```
Optionally, I would like to be able to do it with other package for creating automatic model
tables, such as `stargazer::stargazer`, `texreg::htmlreg` or perhaps other suggestion
```{r lm-tab2, results='asis'}
stargazer::stargazer(reg_mod, type = "html", title = "Third table")
```
```{r lm-tab3, results='asis'}
texreg::htmlreg(reg_mod, caption = "Fourth table")
```
知道如何使回归模型的 tab_model
或任何其他函数与簿记编号一起使用吗?
如 documentation 中所述,如果您在 title/caption 中包含诸如 (\#tab:my-table-lab)
之类的标签,那么 bookdown 支持自动对其他函数生成的 table 进行编号。 =14=]
例如,使用您的 tab_model
table 您可以:
reg_mod <- lm(mpg ~ wt, data = mtcars)
sjPlot::tab_model(reg_mod, title = "(\#tab:tab-model-table) Second table")