This post is a continuation of this one here. I tried to create the regression output table using model summary
as suggested. But I run into some trouble.
# 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
Question 1. This gives me a very strange looking table like this:
Question 2. Also, I would like to add a header using add_header, like you could with kable. How would I do that in modelsummary?
tab %>%
add_header(c(" " = 2, "Donations" = 4, "Crimes (person)" = 4, "Crimes (property)" = 4))%>%
autofit()
Edit: Version 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
Edit1:
I get the same result independent of whether I set kable
or flextable
. I've updated the package and restarted the computer.