1
votes

Using gtsummary package, when I try to style my regression table to a journal format (JAMA in this case), I get the following error:

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

Does anyone know why this is? The code for the data and library is as follows:

# 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")
1

1 Answers

4
votes

The issue is that in gtsummary you don't add a theme like in ggplot2. Instead you have to set the theme. See 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()