使用以下代码,我在下图中生成了 laTex 表。您可能会注意到输出有一些问题。
- 标题不见了
- P值在错误的地方
- 脚注未对齐
任何帮助是极大的赞赏!
library(tidyverse)
library(modelsummary)
library(gt)
data <- as.data.frame(ChickWeight)
mod_control <- lm(weight ~ Time , data = data)
mod_treat <- lm(weight ~ Time + Diet, data = data)
mod_one_list <- list(mod_control, mod_treat)
# coefmap
cm <- c("(Intercept)"="Konstant",
"Time" = "Tid",
"Num.Obs." = "n")
# gof_map
gm <- list(list(raw = "nobs", clean = "N", fmt = 0))
# title
tit <- "En beskrivning här"
# produce table
modelsummary(mod_one_list,
output = "gt",
stars = T,
title = tit,
coef_map = cm,
gof_map = gm,
vcov = "HC1") %>%
tab_spanner(label = '(1)', columns = 2) %>%
tab_spanner(label = "(2)", columns = 3) %>%
tab_footnote("För standardfel använder vi HC1",
locations = cells_body(rows = 1, columns = 2)) %>%
as_latex() %>%
cat()