Skip to contents

This function takes the list outputted by animate_interval() and generates a GIF animation. It is a simple wrapper around the gganimate::animate() function with some defaults. The generated GIF can be saved using the anim_save() function. By default, in the animate() function only 50 states in the data are shown. So, to avoid this gen.animation() defines the default value for the number of frames. Also, the duration argument has a default value equal to the number of states, making the animation slower. More arguments can be passed, which are then passed to animate(), like, height, width, fps, renderer, etc.

Usage

gen.animation(anim, nframes = 2 * anim$nstates, duration = anim$nstate, ...)

Arguments

anim

List outputted by the animate_interval() function containing a gganim object and the number of states in the animation.

nframes

Number of frames. Defaults to double the number of states in the animation.

duration

The duration of animation. Defaults to the number of states in the animation.

...

Extra arguments passed to gganimate::animate().

Value

Does not return any value.

Examples

if (FALSE) {
  a <- animate_interval(cts, "10 year")

  # Generate animation using `gen.animation()`
  if(interactive()){
    gen.animation(a, height = 700, width = 900)
  }

  # Save animation using `anim_save()`
  anim_save("filename.gif")
}