{datamations} provides useful visual encodings to help visualize transformations that occur in various types of data:

  • numeric
  • categorical
  • binary

Numeric data

{datamations} can accept calculations on numeric data and provides encodings on faceted numeric scales.

Test out the functionality on the built in dataset small_salary, which includes synthetic salary data for different types of work and different degree qualifications.

library(datamations)
library(dplyr)
"small_salary %>%
  group_by(Degree) %>%
  summarize(mean = mean(Salary, trim=0.1))" %>%
  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.

Categorical data

{datamations} generates shape encoding for categorical variables passed to group_by or in summary functions. A useful example is in the {palmerpenguins} penguins dataset.

library(palmerpenguins)

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

Binary data

{datamations} similarly can produce visualizations for binary outcomes, displaying variables encoded with opacity and stroke. Binary variables can be passed as a true binary class in R, e.g. TRUE/FALSE, or via a numeric variable encoded to 1/0. This is examplified in the built in dataset jeter_justice, where outcome values are encoded as 1 and 0.

head(jeter_justice)
#>        player year is_hit
#> 1 Derek Jeter 1995      1
#> 2 Derek Jeter 1995      1
#> 3 Derek Jeter 1995      1
#> 4 Derek Jeter 1995      1
#> 5 Derek Jeter 1995      1
#> 6 Derek Jeter 1995      1
"jeter_justice %>%
  group_by(year) %>%
  summarise(mean = mean(is_hit))" %>% datamation_sanddance()

The appearance of this encoding can also be controlled more finely with ggplot aesthetics.