Closed andrewheiss closed 3 years ago
Yeah! This has got to be possible presently. I'll experiment with this today. I'm also wondering whether it'd be a good idea to support a collection of standardized table types like this within gt.
I experimented a little with it yesterday, but got stuck :).
The tricky part about this is that regression models are all different and it's difficult to support every contingency. stargazer hard codes the logic for every possible model, but that takes time and it doesn't support things made by Stan, for instance. huxtable is amazing because it doesn't hard code anything and instead relies on broom. If broom::tidy()
and broom::glance()
can work with a model, huxreg()
can show it (which also allows developers of modeling packages to create their own S3 tidy.*
and glance.*
methods to get support for huxreg()
).
Because huxtable has robust support for selectively pulling model details out and displaying them in a table, I tried different ways of feeding its output to gt()
so that huxreg()
could keep doing all the heavy lifting and gt()
could handle the display, but I couldn't find a good way to do it.
@andrewheiss your work around is extremely helpful.
Whoa, @vincentarelbundock has created a gt-based solution for this! https://github.com/vincentarelbundock/gtsummary
@andrewheiss How did you find out about this?!?
Yeah, I just worked on it over the weekend. It's not quite feature-complete yet, but almost. And it works quite nicely on my machine.
I'd be really grateful if anyone could take a look and tell me how it works on their end. Any suggestion will be most welcome.
If there's interest, I plan to invest some actual effort into this thing. The way the table just pops-out nicely in RStudio's Viewer was a real eye opener for me :)
Ha, the benefits of the GitHub activity stream thing. It said you'd made a new repo :)
I'll check it out and throw some different models at it.
Thanks for this!
@vincentarelbundock
Just wanted to say that I'm pretty impressed with gtsummary. Thanks for getting that going! I also found out about it from the GitHub Activity view. Can't wait to see where it goes!
@rich-iannone Thanks. It was easy to put together, especially given that you are doing all the heavy lifting.
I'm probably going to have a lot of questions (sorry in advance!). For instance, I can't quite figure out the best way to suppress labels, without having a double horizontal rules between grouped tables (this is the mechanics I use to separate coefficients and gof stats).
@vincentarelbundock Questions are definitely okay, no need to apologize for them!
Right now, I don't have a solution for suppressing (or even transforming) the row group labels. Could you file an issue and provide a code example (with screenshot)? Then I could see what I could do about that.
Going to close this since {modelsummary} and {gtsummary} both have this handled!
This is a phenomenal package and I'm a huge fan of the API for creating tables.
At least two other packages provide support for side-by-side regression tables (stargazer and huxtable), but both have limitations: stargazer only supports HTML and TeX and doesn't play well with knitr, and huxtable supports HTML and TeX with minimal Word support, since it creates Markdown tables that don't support column spans or other fancier table features.
I wonder if it would be possible to provide support for regression tables similar to stargazer and huxtable tables, given that the format fits well in the gt API paradigm.
Right now there's a way to fake it very uglyly by extracting coefficients and model details using functions from broom (which huxtable does behind the scenes too), but it'd be cool if there was a less clunky way to make side-by-side regression tables with gt: