-
Notifications
You must be signed in to change notification settings - Fork 200
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
Refactor data_color()
so that it executes faster
#576
Conversation
Let's take a dependency on htmltools >= 1.1.0 and remove the workaround for the scales bug. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comments
Turns out, we already have a min version requirement of |
Just confirmed that removing this code:
does NOT result in non-interpolated colors with Code for reproducing: tbl <-
countrypops %>%
dplyr::filter(country_name == "Mongolia") %>%
dplyr::select(-contains("code")) %>%
tail(10)
tbl[1, ] <- NA
tbl %>%
gt() %>%
data_color(
columns = vars(country_name),
colors = c("red", "orange", "green", "blue")
) With correction code retained, we get the correct colors (subsetting): With that correction code removed, we get an interpolation of colors: |
* master: Refactor `data_color()` so that it executes faster (#576) Update R-CMD-check.yaml (#599) Release gt 0.2.1 (#588) Ensure that row ordering doesn't affect summary row calculations (#556) Update failing example (#586) Remove test of scales behaviour Squelch warnings from tibble 3.0.0/3.0.1 (#557) Bump cache on pkgdown.yaml for GH workflow (#570) Update GH Actions workflow for R CMD check (#568) Update Description of package to be less confusing (#569)
* master: Restore row striping option in stub cells (`row.striping.include_stub = TRUE`) (#564) Refactor `data_color()` so that it executes faster (#576) Update R-CMD-check.yaml (#599) Release gt 0.2.1 (#588) Ensure that row ordering doesn't affect summary row calculations (#556) Update failing example (#586) Remove test of scales behaviour
* master: Fix issues with defining column widths in `cols_width()` (#561) Add `scale_values` arg to `fmt_percent()` (#565) Restore row striping option in stub cells (`row.striping.include_stub = TRUE`) (#564) Refactor `data_color()` so that it executes faster (#576) Update R-CMD-check.yaml (#599) Release gt 0.2.1 (#588) Ensure that row ordering doesn't affect summary row calculations (#556) Update failing example (#586) Remove test of scales behaviour Squelch warnings from tibble 3.0.0/3.0.1 (#557) Bump cache on pkgdown.yaml for GH workflow (#570) Update GH Actions workflow for R CMD check (#568) Update Description of package to be less confusing (#569)
* master: Rewrite of RTF building functions and `as_rtf()` (#638) v0.2.2 Release Candidate (#629) Settable font options (#591) Add options for sig figs / inclusion of trailing dec marks (#546) Fix issues with defining column widths in `cols_width()` (#561) Add `scale_values` arg to `fmt_percent()` (#565) Restore row striping option in stub cells (`row.striping.include_stub = TRUE`) (#564) Refactor `data_color()` so that it executes faster (#576) Update R-CMD-check.yaml (#599) Release gt 0.2.1 (#588) Ensure that row ordering doesn't affect summary row calculations (#556)
* master: (30 commits) Spanner alignment correction (#662) PEN currency fix (#663) Fix for `gtsave()` when saving an image and specifying a `path` value (#592) Rewrite of RTF building functions and `as_rtf()` (#638) v0.2.2 Release Candidate (#629) Settable font options (#591) Add options for sig figs / inclusion of trailing dec marks (#546) Fix issues with defining column widths in `cols_width()` (#561) Add `scale_values` arg to `fmt_percent()` (#565) Restore row striping option in stub cells (`row.striping.include_stub = TRUE`) (#564) Refactor `data_color()` so that it executes faster (#576) Update R-CMD-check.yaml (#599) Release gt 0.2.1 (#588) Ensure that row ordering doesn't affect summary row calculations (#556) Update failing example (#586) Remove test of scales behaviour Squelch warnings from tibble 3.0.0/3.0.1 (#557) Bump cache on pkgdown.yaml for GH workflow (#570) Update GH Actions workflow for R CMD check (#568) Update Description of package to be less confusing (#569) ...
The
data_color()
function was seen to be extremely slow. Reason for this was a combination of missed opportunities for vectorization, overuse of loops, and longer than necessary routes to an otherwise simple addition of_styles
rows.Below is reproducible code that would otherwise take 5-8 s before the changes in this PR (it now takes about 0.15 seconds):
Fixes: #543