View source: R/transition-manual.R
transition_manual | R Documentation |
This transition allows you to map a variable in your data to a specific frame in the animation. No tweening of data will be made and the number of frames in the animation will be decided by the number of levels in the frame variable.
transition_manual(frames, ..., cumulative = FALSE)
frames |
The unquoted name of the column holding the frame membership. |
... |
Additional variables |
cumulative |
Keep data from previous frames as part of the current frame data |
transition_states
makes the following variables available for string
literal interpretation, in addition to the general ones provided by
animate()
:
previous_frame The name of the last frame the animation was at
current_frame The name of the current frame
next_frame The name of the next frame in the animation
transition_manual
does not link rows across data to the same graphic
element. Every frame is a discrete state and no animation between the states
is done.
It is possible to use variables calculated by the statistic to define the
transition. Simply inclose the variable in stat()
in the same way as when
using computed variables in aesthetics.
Other transitions:
transition_components()
,
transition_events()
,
transition_filter()
,
transition_layers()
,
transition_null()
,
transition_reveal()
,
transition_states()
,
transition_time()
anim <- ggplot(mtcars, aes(factor(gear), mpg)) +
geom_boxplot() +
transition_manual(gear)
# Using `cumulative = TRUE` to keep data from older frames
anim2 <- ggplot(mtcars, aes(factor(gear), mpg)) +
geom_boxplot() +
transition_manual(gear, cumulative = TRUE)
# Use `factor()` to set the order of the frames
anim3 <- ggplot(mtcars, aes(factor(gear), mpg)) +
geom_boxplot() +
transition_manual(factor(gear, levels = c('4', '3', '5')))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.