datamations allows the visualization of dplyr::group_by calls containing up to three variables.

group_by api

The datamations_sanddance call can finish with a group_by call, displaying proportional data faceted by the grouping variables.

Single grouping variable

library(datamations)
library(dplyr)

"small_salary %>%
  group_by(Work, Degree)"
#> [1] "small_salary %>%\n  group_by(Work, Degree)"

Two grouping variables

"small_salary %>%
  group_by(Work, Degree)" %>%
  datamation_sanddance()

Three grouping variables

library(palmerpenguins)

"penguins %>%
  group_by(sex, island, species)" %>%
  datamation_sanddance()

summarizing and filtering by group

The datamations_sanddance call can also show the filtering and summarization of data based on group facets.

group_by into filter

"small_salary %>%
  group_by(Degree) %>%
  filter(Salary > 90)" %>%
  datamation_sanddance()

group_by into summarize

"small_salary %>%
  group_by(Degree) %>%
  summarize(mean = mean(Salary))" %>%
  datamation_sanddance()
#> Warning: Returning more (or less) than 1 row per `summarise()` group was deprecated in
#> dplyr 1.1.0.
#>  Please use `reframe()` instead.
#>  When switching from `summarise()` to `reframe()`, remember that `reframe()`
#>   always returns an ungrouped data frame and adjust accordingly.
#>  The deprecated feature was likely used in the datamations package.
#>   Please report the issue to the authors.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
"penguins %>% group_by(sex, island, species) %>% summarize(mean = median(bill_length_mm))" %>% datamation_sanddance()