playitbyr Getting Started Support--Help, Bugs, and Documentation GitHub Sonification Resources

sonfacet {playitbyr}R Documentation

Simple faceting

Description

Allows creation of ‘facets’ for a sonification, i.e. to separately sonify different groups of a dataset, one after another. Analogous to ggplot2's facet_wrap.

Usage

  sonfacet(facet = NULL, scales = "fixed", pause = 0.5)

Arguments

facet

Variable to split by

scales

Should scales be fixed ("fixed", the default), or free ("free")

pause

Length of pause, in seconds, between each facet

Details

When added onto a sonify object, this function splits the data by the variable given in facets and creates separate sonifications for each subset of the data. All factor levels not used in the data will automatically be dropped.

Note

Unlike facet_wrap, this function does not take a formula–instead it only takes the name of the data variable to split by.

Examples

df <- data.frame(pits = c(0, 1, 1, 2, 2, 3),
                   tims = c(0, 1, 0, 1, 0, 1),
                   facs = c(0, 0, 1, 1, 2, 2))
x <- sonify(df, sonaes(time = tims, pitch = pits)) + shape_scatter(dur = 1) +
   scale_time_continuous(c(0, 1)) + scale_pitch_continuous(c(8, 8.25)) +
     sonfacet(facs, pause = 1)

## Not run: x