jthomasmock / gtExtras

A Collection of Helper Functions for the gt Package.
https://jthomasmock.github.io/gtExtras/
Other
195 stars 27 forks source link

Improve colors in merge `gt_merge_stack()` #39

Closed mrcaseb closed 2 years ago

mrcaseb commented 2 years ago

Currently the colors argument is directly used in the html string that creates the merged and stacked cells. Since some R colornames are not known in html they won't work at all. See

dat <- tibble::tibble(
  a = c(1:4, NA),
  b = c(rep(90, 2), NA, 98, 99)
) 
dat
#> # A tibble: 5 x 2
#>       a     b
#>   <int> <dbl>
#> 1     1    90
#> 2     2    90
#> 3     3    NA
#> 4     4    98
#> 5    NA    99

gt::gt(dat) |> 
  gtExtras::gt_merge_stack(a, b, colors = c("red2", "black"))

grafik

This updated translates the colornames to hcl with scales. This allows non html colornames that are built-in to R. Above code will output this: grafik

mrcaseb commented 2 years ago

Notes:

jthomasmock commented 2 years ago

Hey @mrcaseb - thanks! The R Cmd Check notes are plentiful - got a bit of work to do on my end before CRAN 😉

There was also an open request for dynamically setting the colors (ie by team), so I'll sit on this PR for a little bit.

mrcaseb commented 2 years ago

Sidenote: @guga31bb wrote a helper function that creates a script to silence check notes on tidy evaluation.

https://github.com/guga31bb/ngscleanR/blob/master/data-raw/generate_silence_eval_notes.R

You might want to use it.

mrcaseb commented 2 years ago

@jthomasmock I have merged the current master into the PR.

However, now all checks are failing because the remote repository for the non CRAN dependency webshot2 is missing. Additionally I highly recommend switching to v2 of some r-lib actions. I can fix the above mentioned stuff but I am unsure how many changes you want in this PR. So I'll keep it as is for now and wait for your answer.