Closed kdzhang closed 7 months ago
It seems that some other packages also have this problem: https://github.com/glin/reactable/issues/21
Hi @kdzhang , thanks a lot for reporting this issue!
Unfortunately, this one is out of my control, as this is a problem in an "upstream" package. The documentation may not be clear enough on this point, but modelsummary
doesn't actually draw the tables itself. Instead, the package outsources the table drawing to one of four supported "backends": kableExtra
, gt
, flextable
, and huxtable
.
The default table backend is kableExtra
, and if you try this Rmd file, you notice the same problem with a very minimalist kableExtra
table:
---
title: "R Notebook"
output: html_document
---
```{r}
library(kableExtra)
dat <- data.frame(a = 1:2, b = 2:3)
kbl(dat)
I can see 2 main avenues for solutions:
1. Use a different backend. In my attempts, I was able to replicate you problem with the default, but the other backends seem to work fine (although they background is white and a bit ugly with all of them). So you would type: `modelsummary(mod, output="gt")`, or you would set a global option at the top of your document to change the default backend in all of your subsquent calls: `options(modelsummary_default="gt")`
2. Open an Issue on [the `kableExtra` repository](https://github.com/haozhu233/kableExtra) and hope that the maintainer has time for a solution. If you decide to open an issue, I think a minimal `kableExtra`-specific example like the one I posted above is probably best, and the link you found to the `reactable` repo seems useful (though I don't understand the exact problem after having read it).
Hi @vincentarelbundock , thank you a lot for the very timely response! I think the gt
solutions works well enough for me at this time.
And it seems that using kable
instead of kbl
will fix the display issue in your minimum example. I will report this to kableExtra
team once I have a minute. Thanks a lot!
There's a temporary solution here too, which involves injecting some extra CSS to the table displayed in RStudio https://github.com/haozhu233/kableExtra/issues/689#issuecomment-1170167006
But it's still a kableExtra issue, not a modelsummary issue. It might be possible to permanently add the CSS override in kableExtra itself as long as it doesn't break output in light themes or non-RStudio editors, etc.
Thanks for the follow up and the alternative solution! I'll just leave the issue open to make it easier to find in case someone else runs into it.
I have the same issue when using knitr::kable(). If you look closely you can see the output, but it looks like a negative. If I click to view the table in a new window, the text becomes visible.
using gt(dff), the table renders as it should.
Yeah, it's an issue with kableExtra. There's a workaround for it here: https://github.com/haozhu233/kableExtra/issues/689#issuecomment-1170167006 (I actually have that print.kableExtra()
function stored as a keyboard snippet in RStudio so I can run it whenever I need to look at kableExtra-based tables)
Ah and there might be a weird inconsistent bug in RStudio about this.
With the latest daily version of RStudio, and with no other packages loaded, it should look like this with knitr::kable()
, with white text:
kableExtra::kable()
should show the same thing:
kableExtra::kbl()
shows everything with a white background:
And with the custom print.kableExtra()
function loaded and with kable_styling()
, it's correct:
However, with slightly older versions of RStudio, knitr::kable()
shows up incorrectly…
…but once you switch to a different tab in the editor window and switch back to the original document, or move the RStudio window to a different screen, or do something else to trigger a refresh of the document, the text shows up correctly, which is bizarre
I believe I'm using the latest version of RStudio, at least that is what RStudio reports when I check for updates. As my previous post shows...this RStudio version seems to have a rendering issue.
Does switching to a different tab and coming back to the Rmd file update it for you? In the daily builds for version 2022.03, forcing a document refresh will make the text show correctly
I'm opening an issue at RStudio's repository now
Thanks a lot @andrewheiss . I don't use Rstudio, so I'm not confronted with this issue regularly, and it's kinda hard for me to diagnose, so this is very helpful.
Does switching to a different tab and coming back to the Rmd file update it for you? In the daily builds for version 2022.03, forcing a document refresh will make the text show correctly
Yes, I just double checked...Same result if I select to 'open in a new window', the text eventually is displayed. Until I actually take this next step, all I can barely makeout is a 'negative' of the text otherwise.
fixed upstream in kableExtra.
Upcoming modelsummary 2.0.0 will use tinytable as default (breaking change), so this is no longer as relevant.
Hi, Thanks for the great package! I encountered the following problem when I tried to use this package.
When use dark mode in R-studio, the table does not show properly:
Use a light theme solves the problem:
Please copy the output of these commands: