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

Header row incorrectly added when variable has spaces in the name #70

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

Comments

@ddsjoberg
Copy link
Collaborator

The example below has two identical regression models: one with covariate mpg and the other miles per gallon. The covariate with with spaces in the name incorrectly has a header row added.

library(broom.helpers)

# header row incorrectly added when MPG has spaces in the variable name
lm(hp ~ `miles per gallon`,
   mtcars %>% dplyr::rename(`miles per gallon` = mpg)) %>%
  tidy_plus_plus(add_header_rows = TRUE)
#> # A tibble: 2 x 16
#>   term  variable var_label var_class var_type var_nlevels header_row contrasts
#>   <chr> <chr>    <chr>     <chr>     <chr>          <int> <lgl>      <chr>    
#> 1 <NA>  miles p~ miles pe~ numeric   continu~          NA TRUE       <NA>     
#> 2 `mil~ miles p~ miles pe~ numeric   continu~          NA FALSE      <NA>     
#> # ... with 8 more variables: reference_row <lgl>, label <chr>, estimate <dbl>,
#> #   std.error <dbl>, statistic <dbl>, p.value <dbl>, conf.low <dbl>,
#> #   conf.high <dbl>

# correct behaviour when using original `mpg` variable name
lm(hp ~ mpg, mtcars) %>%
  tidy_plus_plus(add_header_rows = TRUE)
#> # A tibble: 1 x 16
#>   term  variable var_label var_class var_type var_nlevels header_row contrasts
#>   <chr> <chr>    <chr>     <chr>     <chr>          <int> <lgl>      <chr>    
#> 1 mpg   mpg      mpg       numeric   continu~          NA NA         <NA>     
#> # ... with 8 more variables: reference_row <lgl>, label <chr>, estimate <dbl>,
#> #   std.error <dbl>, statistic <dbl>, p.value <dbl>, conf.low <dbl>,
#> #   conf.high <dbl>

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

@larmarange
Copy link
Owner

Thanks for having identified that bug. 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