hughjonesd / huxtable

An R package to create styled tables in multiple output formats, with a friendly, modern interface.
http://hughjonesd.github.io/huxtable
Other
321 stars 28 forks source link

huxreg: current dev version doesn't rename model statistics #58

Closed jacob-long closed 6 years ago

jacob-long commented 6 years ago

To clarify the issue, normally if we provide a named vector to the statistics = argument, it not only selects the coefficients from broom::glance that are included in the vector but also labels them according to the names of the vector.

It appears abbafe9 caused this regression, but I don't grasp what's going on well enough to be sure why it has this effect and what will preserve the change you intended to make with that commit while also fixing this new issue. I can confirm the naming works appropriately with 39209b6.

Current version:

fit <- lm(mpg ~ wt + cyl, data = mtcars)
huxtable::huxreg(fit, statistics = c("N" = "nobs"))
─────────────────────────────────────────────────
                                   (1)           
                        ─────────────────────────
  (Intercept)                        39.686 ***  
                                     (1.715)     
  wt                                 -3.191 ***  
                                     (0.757)     
  cyl                                -1.508 **   
                                     (0.415)     
                        ─────────────────────────
  nobs                               32          
─────────────────────────────────────────────────
  *** p < 0.001; ** p < 0.01; * p < 0.05.  

Reverting to 39209b6

devtools::install_github("hughjonesd/huxtable", ref = "39209b6")
huxtable::huxreg(fit, statistics = c("N" = "nobs"))
───────────────────────────────────────────────
                                 (1)           
                       ────────────────────────
  (Intercept)                      39.686 ***  
                                   (1.715)     
  wt                               -3.191 ***  
                                   (0.757)     
  cyl                              -1.508 **   
                                   (0.415)     
                       ────────────────────────
  N                                32          
───────────────────────────────────────────────
  *** p < 0.001; ** p < 0.01; * p < 0.05.  
hughjonesd commented 6 years ago

It'll be that call to intersect, munging names I bet. Data types in R are so much more complex than they seem... thanks for this.

-- Sent from Gmail Mobile