R: Tween a list of data.frames representing states

tween_states {tweenr} | R Documentation

## Tween a list of data.frames representing states

### Description

This function is intended to create smooth transitions between states of data. States are defined as full data.frames or data.frames containing only the columns with change. Each state can have a defined period of pause, the transition length between each states can be defined as well as the easing function.

### Usage

    tween_states(data, tweenlength, statelength, ease, nframes)

### Arguments

`data` | A list of data.frames. Each data.frame must contain the same number of rows, but only the first data.frame needs to contain all columns. Subsequent data.frames need only contain the columns that shows change.
`tweenlength` | The lengths of the transitions between each state.
`statelength` | The length of the pause at each state.
`ease` | The easing functions to use for the transitions. See details.
`nframes` | The number of frames to generate. The actual number of frames might end up being higher depending on the regularity of `tweenlength` and `statelength`.

### Value

A data.frame with the same columns as the first data.frame in `data`, but replicated `nframes` times. An additional column called `.frame` will be added giving the frame number.

### See Also

Other data.frame tween: `tween_along()`, `tween_appear()`, `tween_components()`, `tween_elements()`, `tween_events()`

### Examples

    data1 <- data.frame(
      x = 1:20,
      y = 0,
      colour = 'forestgreen',
      stringsAsFactors = FALSE
    )
    data2 <- data1
    data2$x <- 20:1
    data2$y <- 1

    data <- tween_states(list(data1, data2), 3, 1, 'cubic-in-out', 100)

[Package tweenr version 1.0.2 Index]