tween_states: Tween a list of data.frames representing states

View source: R/tween_states.R

tween_statesR Documentation

Tween a list of data.frames representing states


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.


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



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.


The lengths of the transitions between each state.


The length of the pause at each state.


The easing functions to use for the transitions. See details.


The number of frames to generate. The actual number of frames might end up being higher depending on the regularity of tweenlength and statelength.


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()


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)

tweenr documentation built on Sept. 6, 2022, 9:05 a.m.