使用 gtsummary 包进行回归 table 的日志主题会引发错误

Journal themes for regression table using gtsummary package throws an error

使用 gtsummary 包,当我尝试将回归 table 设置为期刊格式(在本例中为 JAMA)时,出现以下错误:

  Error in theme_gtsummary_journal(., journal = "jama") : 
  'list' object cannot be coerced to type 'logical'

有人知道这是为什么吗?数据和库的代码如下:

# load packages
library(gtsummary)

# dummy data 
crime <-data.frame(State = sample(c("SF", "AR", "NYC","MN"),13000,replace = TRUE),
                   Year = sample(as.factor(c(1990, 2000)),13000, replace = TRUE)
                   )

# multinom model with visual  
glm(Year ~ State, data = crime, family = binomial) %>%
  tbl_regression(exponentiate = TRUE) %>%
  theme_gtsummary_journal(journal = "jama")

问题是在 gtsummary 中您没有像在 ggplot2 中那样添加主题。相反,您必须设置主题。见 gtsummary themes vignette:

# load packages
library(gtsummary)

set.seed(42)

# dummy data 
crime <-data.frame(State = sample(c("SF", "AR", "NYC","MN"),13000,replace = TRUE),
                   Year = sample(as.factor(c(1990, 2000)),13000, replace = TRUE)
)

tab <- glm(Year ~ State, data = crime, family = binomial) %>%
  tbl_regression(exponentiate = TRUE)

# Set theme
theme_gtsummary_journal(journal = "lancet")

tab

# Reset theme
reset_gtsummary_theme()