The datamations API can visualize the summarization of variables with several dplyr verbs, like summarize()/summarise(), count(), and tally()

summary functions

datamations_sanddance has special animations to visualize certain common summary functions passed to summarize. These custom animations include:

  • mean
  • median
  • max/min
  • quantile

mean of a variable

library(datamations)
library(dplyr)
"small_salary %>%
  group_by(Work) %>%
  summarise(mean_salary = 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.

median of a variable

"small_salary %>%
  group_by(Work) %>%
  summarise(median_salary = median(Salary))" %>%
  datamation_sanddance()

min and max of a variable

"small_salary %>%
  group_by(Work) %>%
  summarise(min_salary = min(Salary))" %>%
  datamation_sanddance()
"small_salary %>%
  group_by(Work) %>%
  summarise(max_salary = max(Salary))" %>%
  datamation_sanddance()

quantile() function

The summarize function includes the capacity to pass some parameterized functions that result in custom animations. Currently datamations supports the quantile() function with the probs parameter as an example of this capability.

"small_salary %>%
  group_by(Degree) %>%
  summarise(quan = quantile(Salary, probs = 0.01))" %>%
  datamation_sanddance()

Other summary functions

Common summary functions may include count-like operations, like n_distinct.

n_distinct()

library(palmerpenguins)

"penguins %>%
  group_by(island) %>%
  summarise(n = n_distinct(species))" %>%
  datamation_sanddance()

You can find the API can support a large variety of mathematical functions and dplyr functions

"small_salary %>%
  group_by(Degree) %>%
  summarize(floor_salary = trunc(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.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
"small_salary %>%
  group_by(Degree) %>%
  summarize(first_salary = first(Salary))" %>%
  datamation_sanddance()
"small_salary %>%
  group_by(Degree) %>%
  summarize(lagged_salary = lag(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.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.

count() and tally()

datamations treats count() and tally() calls equivalently to group_by() + summarize(n = n()).

"small_salary %>%
  group_by(Degree) %>%
  count(Salary)" %>%
  datamation_sanddance()