jthomasmock / gtExtras

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

Allow tidyselect and rlang .data prefix in `gt_sparkline.R` #20

Closed ddsjoberg closed 2 years ago

ddsjoberg commented 2 years ago

Hello!

I am writing a simple wrapper for gt_sparkline() for {gtsummary} tables. One issue I ran into was that the gt_sparkline(column=) argument couldn't accept the rlang .data prefix. The update also allows users to utilize tidyselect selectors. Example below!

library(gt)

mtcars %>%
  dplyr::group_by(cyl) %>%
  # must end up with list of data for each row in the input dataframe
  dplyr::summarize(mpg_data = list(mpg), .groups = "drop") %>%
  gt() %>%
  gt_sparkline(.data$mpg_data)
jthomasmock commented 2 years ago

Thanks! I may take that approach in a few other places, hadn't really considered need for the .data prefix.

ddsjoberg commented 2 years ago

Thank you @jthomasmock !