Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modelsum(): catch the error #365

Open
kekec3778 opened this issue Dec 14, 2023 · 0 comments
Open

modelsum(): catch the error #365

kekec3778 opened this issue Dec 14, 2023 · 0 comments

Comments

@kekec3778
Copy link

A short reprex:

a <- factor(c(rep("a", 5), rep("b", 5)), levels = c("a", "b"))
b <- factor(c(rep(NA_character_, 10)), levels = c("a", "b"))
c <- factor(c(sample(x = c("x", "y", "z"), size = 10, replace = TRUE)), levels = c("x", "y", "z"))
df <- tibble(a, b, c)

mod1 <- glm(formula = a ~ c, data = df, family = "binomial")  # works fine
mod2 <- glm(formula = a ~ b, data = df, family = "binomial") # error

Now, try to get this results with modelsum():

tab.mod <-
  arsenal::modelsum(
    formula = a ~ b + c,
    data = df, 
    family = "binomial",  
    adjust = ~ 1,   
    control = modelsum.control(
      show.intercept = FALSE,
      binomial.stats = c("OR", "CI.lower.OR", "CI.upper.OR", "p.value", "Nmiss")
    )
  )

Of course it fails, because a ~ b.
Is it possible to catch such errors and anyway show the results with default values for example "NA" or similar ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant