modelsummary
modelsummary(models1,
output = "table.docx")
modelsummary(models2,
output = "table.docx")
modelsummary
使用
Named模型列表(稍后将用于临时文件名称的名称):
library(modelsummary)
library(officer)
the_models <- list(
m1 = lm(Sepal.Length ~ Species, iris),
m2 = lm(Sepal.Length ~ Sepal.Width + Species, iris)
)
all_tables_doc <- read_docx()
all_tables_doc
(在上面的管道中,您可以进一步的元素toge page preaks或每张表格字幕。)
names(the_models) |>
Map(f = \(name){
file_name <- file.path(tempdir(), paste0(name,'.docx'))
modelsummary(the_models[[name]], file_name)
all_tables_doc <- all_tables_doc |>
body_add_docx(file_name)
name
})
print(all_tables_doc, 'all_tables.docx')