Skip to content
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

Adding "Identity Boxplot" to gt_plt_dist() #136

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

beansrowning
Copy link

Rationale

I use R (or Python) for ETL and write simple summary statistics while processing the data. I recently wanted to visualize a five-num summary I wrote out for each dataset as a boxplot within a {gt} table, but found that {gtExtras} didn't allow this natively, since it's always assumed that the full set of data is present in the list col passed. In my case, it is not always possible to include the full dataset--nor advisable, due to size--but I'd still like to construct rudimentary boxplots in my table.

It seems like an easy addition, since {ggplot2} already allows this behavior natively (and {sparkline} does as well via spk_chr(., type="box", raw=TRUE)).

Changes

  • Adds an additional type to gt_plt_dist() called "boxplot_identity" that allows a user to pass variables to define boxplot via ggplot's stat="identity" option rather than raw data
  • Updated unit tests
  • Updated docs

Example:

mtcars |>
  dplyr::group_by(cyl) |>
  dplyr::summarize(mpg_data = list(stats::fivenum(mpg)), .groups = "drop") |>
  gt() |>
  gt_plt_dist(mpg_data, type = "boxplot_identity")

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant