以格式良好的结果提取 word 文档中的回归摘要()输出
Extract regression summary() output in word document in a nicely formated resut
有没有一种方法可以像我在下面附上的相关性 table 那样以很好的乳胶格式提取回归模型的摘要? table 应在 word 文档中使用 knitr 导出或至少保存在 word 文档中。
# install.packages("dplyr")
# install.packages("kableExtra")
library(dplyr)
library(kableExtra)
mlm1 <- lm(mpg ~ . , data = mtcars)
summary(mlm1)
summary(mlm1) %>%
kbl(caption="Table 1: Summary Statistics of Financial Well-Being
Score by Gender and Education",
format= "html",
align="r") %>%
kable_classic(full_width = F, html_font = "helvetica")
您可以使用 broom
包:
library(dplyr)
library(kableExtra)
library(broom)
mlm1 <- lm(mpg ~ . , data = mtcars)
summary(mlm1)
tidy(mlm1) %>% kbl(caption="Table 1: Summary Statistics of Financial Well-Being
Score by Gender and Education",
format= "html",
align="r") %>%
kable_classic(full_width = F, html_font = "helvetica")
此外,您可以通过 broom::glance(mlm1)
.
报告有关整个模型(即 R-squared、AIC 等)的信息
有没有一种方法可以像我在下面附上的相关性 table 那样以很好的乳胶格式提取回归模型的摘要? table 应在 word 文档中使用 knitr 导出或至少保存在 word 文档中。
# install.packages("dplyr")
# install.packages("kableExtra")
library(dplyr)
library(kableExtra)
mlm1 <- lm(mpg ~ . , data = mtcars)
summary(mlm1)
summary(mlm1) %>%
kbl(caption="Table 1: Summary Statistics of Financial Well-Being
Score by Gender and Education",
format= "html",
align="r") %>%
kable_classic(full_width = F, html_font = "helvetica")
您可以使用 broom
包:
library(dplyr)
library(kableExtra)
library(broom)
mlm1 <- lm(mpg ~ . , data = mtcars)
summary(mlm1)
tidy(mlm1) %>% kbl(caption="Table 1: Summary Statistics of Financial Well-Being
Score by Gender and Education",
format= "html",
align="r") %>%
kable_classic(full_width = F, html_font = "helvetica")
此外,您可以通过 broom::glance(mlm1)
.