View source: R/tween_components.R
tween_components | R Documentation |
This function is much like tween_elements()
but with a slightly different
syntax and support for many of the newer features such as enter/exits and
tween phase identification. Furthermore it uses tidy evaluation for time and
id, making it easier to change these on the fly. The biggest change in terms
of functionality compared to tween_elements()
is that the easing function
is now given per column and not per row. If different easing functions are
needed for each transition then tween_elements()
is needed.
tween_components(
.data,
ease,
nframes,
time,
id = NULL,
range = NULL,
enter = NULL,
exit = NULL,
enter_length = 0,
exit_length = 0
)
.data |
A data.frame with components at different stages |
ease |
The easing function to use. Either a single string or one for each column in the data set. |
nframes |
The number of frames to calculate for the tween |
time |
An unquoted expression giving the timepoint for the different
stages of the components. Will be evaluated in the context of |
id |
An unquoted expression giving the component id for each row. Will
be evaluated in the context of |
range |
The range of time points to include in the tween. If |
enter , exit |
functions that calculate a start state for new observations
that appear in |
enter_length , exit_length |
The lenght of the opening and closing
transitions if |
A data.frame with the same columns as .data
along with .id
giving
the component id, .phase
giving the state of each component in each frame,
and .frame
giving the frame membership of each row.
Other data.frame tween:
tween_along()
,
tween_appear()
,
tween_elements()
,
tween_events()
,
tween_states()
from_zero <- function(x) {x$x <- 0; x}
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),
id = c(1, 1, 1, 2, 2, 2)
)
data <- tween_components(data, 'cubic-in-out', nframes = 100, time = time,
id = id, enter = from_zero, enter_length = 4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.