'set slower frame rate or longer duration for gganimate

when making animation from ggplot using gganimate, I need to set a lower pace to allow people to read data.

Reading documentation (hard to find options) seems that "nframes" is the proper setting. But I can't slow the animation or set the duration. Any of both approaches would be fine

library("gganimate")
library("tidyverse")

p <- ggplot(airquality, aes(Day, Temp, color = Month)) +
  transition_time(Month) +
  labs(title = 'Month is {frame_time}') +
  geom_path(aes(group = Month), size = 1)

animate(p, nframes = 100)

Error in device(files[i], ...) : unused argument (nframes = 100)


Solution 1:[1]

Not sure why you received that error, but you can set the frame rate in the animate() function call:

animate(p, nframes = 100, fps=3)

Solution 2:[2]

What helped me was the duration (in seconds) option, which in combination with fps (relates to smootheness of the animation) allows you to finely tune the length and smootheness of the animation:

animate(p, fps = 10, duration = 30)

Solution 3:[3]

  1. If you have any comma's at the end of a line remove it
  2. Make sure you have the same number of lines under each header

Now for every block

  1. Place the cursor at start of line Header2
  2. Now with Ctrl+Alt+DownArrow add multi Cursors or use Shift+Alt+MouseClick at the last line belonging to Header2
  3. Select the whole line: Shift+End
  4. Cut the content: Ctrl+X
  5. With ArrowUp move the cursors up so the first cursor is on the line with Header1
  6. Got to end of line, Add , , Paste Header2 lines: End , Ctrl+V

You can also start with the last block and add it to the previous block, now the cursors can stay on the same line to pick up the content and move it to the end of the previous block.

At the end remove all the empty lines.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alan Dursun
Solution 2 David
Solution 3 rioV8