这篇文章是这里这篇文章的延续。我尝试model summary
按照建议使用创建回归输出表。但我遇到了一些麻烦。
# Code from the original question
library(mfx)
library(dplyr)
year <- rep(2014:2015, length.out = 10000)
group <- sample(c(0,1,2,3,4,5,6), replace=TRUE, size=10000)
value <- sample(10000, replace = T)
female <- sample(c(0,1), replace=TRUE, size=10000)
smoker <- sample(c(0,1), replace=TRUE, size=10000)
dta <- data.frame(year = year, group = group, value = value, female=female, smoker = smoker)
table_list <- dta %>%
group_by(year, group) %>%
group_split()
model_list <- lapply(table_list, function(x) probitmfx(smoker ~ female, data = x))
# New code
library(modelsummary)
tab <- modelsummary(model_list, output = 'flextable',
stars = TRUE,
title = "Table x.", gof_omit = 'IC|Log|Adj')
tab
问题 2. 另外,我想使用 add_header 添加标头,就像您可以使用 kable 一样。我将如何在模型摘要中做到这一点?
tab %>%
add_header(c(" " = 2, "Donations" = 4, "Crimes (person)" = 4, "Crimes (property)" = 4))%>%
autofit()
编辑:版本 R
This is the version platform
x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 6.1
year 2019
month 07
day 05
svn rev 76782
language R
version.string R version 3.6.1 (2019-07-05)
nickname Action of the Toes
编辑1:
无论我设置kable
还是,我都会得到相同的结果flextable
。我已经更新了软件包并重新启动了计算机。