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

tidy_remove_intercept() removes terms from model (when they are named horribly) #44

Closed
ddsjoberg opened this issue Oct 2, 2020 · 1 comment

Comments

@ddsjoberg
Copy link
Collaborator

This is VERY much an edge case, but wanted to let you know. It seems that if a variable name has a + in it, tidy_remove_intercept() will remove both the intercept and the variable from the model. If this is a complicated fix, perhaps just a message to the user, "more than one row was removed from the table. possible error occurred likely due to unusual naming conventions used for terms."

library(gtsummary)

trial2 <- 
  trial %>% 
  dplyr::mutate(`treatment +name` = trt)


glm(response ~ `treatment +name`, 
    trial2, 
    family = binomial(link = "logit")) %>%
  broom.helpers::tidy_and_attach() %>%
  broom.helpers::tidy_remove_intercept()
#> # A tibble: 0 x 8
#> # ... with 8 variables: term <chr>, variable <chr>, var_class <chr>,
#> #   var_type <chr>, estimate <dbl>, std.error <dbl>, statistic <dbl>,
#> #   p.value <dbl>

Created on 2020-10-02 by the reprex package (v0.3.0)

@larmarange
Copy link
Owner

Thanks for having opened the issue.

The problem arrives in fact earlier when identifying variables, due to the presence in the variable name of a character with a special meaning in a regular expression.

It should have been fixed now.

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

2 participants