gen_keyframe | R Documentation |
This is a generator version of tween_state()
and its utility functions. It
returns a generator that can be used with get_frame()
and
get_raw_frames()
to extract frames for a specific time point scaled between
0 and 1.
gen_keyframe(keyframe = NULL, pause = 0) add_pause(.data, pause = 0) add_keyframe( .data, keyframe, ease, length, id = NULL, enter = NULL, exit = NULL )
keyframe |
A data frame to use as a keyframe state |
pause |
The length of the pause at the current keyframe |
.data |
A data.frame to start from. If |
ease |
The easing function to use. Either a single string or one for each column in the data set. |
length |
The length of the transition |
id |
The column to match observations on. If |
enter, exit |
functions that calculate a start state for new observations
that appear in |
A keyframe_generator
object
Other Other generators:
gen_along()
,
gen_at()
,
gen_components()
,
gen_events()
df1 <- data.frame( country = c('Denmark', 'Sweden', 'Norway'), population = c(5e6, 10e6, 3.5e6) ) df2 <- data.frame( country = c('Denmark', 'Sweden', 'Norway', 'Finland'), population = c(6e6, 10.5e6, 4e6, 3e6) ) df3 <- data.frame( country = c('Denmark', 'Norway'), population = c(10e6, 6e6) ) to_zero <- function(x) { x$population <- 0 x } gen <- gen_keyframe(df1, 10) %>% add_keyframe(df2, 'cubic-in-out', 35, id = country, enter = to_zero) %>% add_pause(10) %>% add_keyframe(df3, 'cubic-in-out', 35, id = country, enter = to_zero, exit = to_zero) %>% add_pause(10) get_frame(gen, 0.25)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.