tween_elements {tweenr} | R Documentation |
Create frames based on individual element states
Description
This function creates tweens for each observation individually, in cases where the data doesn't pass through collective states but consists of fully independent transitions. Each observation is identified by an id and each state must have a time associated with it.
Usage
tween_elements(data, time, group, ease, timerange, nframes)
Arguments
data |
A data.frame consisting at least of a column giving the observation id, a column giving timepoints for each state and a column giving the easing to apply when transitioning away from the state. |
time |
The name of the column holding timepoints |
group |
The name of the column holding the observation id |
ease |
The name of the column holding the easing function name |
timerange |
The range of time to span. If missing it will default to
|
nframes |
The number of frames to generate. If missing it will default
to |
Value
A data.frame with the same columns as data
except for the
group and ease columns, but replicated nframes
times. Two additional
columns called .frame
and .group
will be added giving the frame
number and observation id for each row.
See Also
Other data.frame tween:
tween_along()
,
tween_appear()
,
tween_components()
,
tween_events()
,
tween_states()
Examples
data <- data.frame(
x = c(1, 2, 2, 1, 2, 2),
y = c(1, 2, 2, 2, 1, 1),
time = c(1, 4, 10, 4, 8, 10),
group = c(1, 1, 1, 2, 2, 2),
ease = rep('cubic-in-out', 6)
)
data <- tween_elements(data, 'time', 'group', 'ease', nframes = 100)