From the course: R for Data Science: Lunch Break Lessons

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Animating ggplot

Animating ggplot

- [Instructor] R provides some excellent data visualization tools, things such as graphs and plots. Your data story will be much more compelling if you can animate that data. And gganimate works with the ggplot package to provide animated plots. Let's take a look at how to do this. In lines four and five, I've used the library command to bring in gganimate and dplyr. Then in line eight, I've used split to simplify chick weight into just one set of data. Now, let's create just a standard, static plot using ggplot and I've set that up in lines 11 and 12 and what you see is a standard ggplot with a series of dots representing the data. Now, let's animate that information. Start in line 15. There's our good friend ggplot, and in line 16, geom_point and you'll notice that that's identical to lines 11 and 12 that we used to produce a static version of this data. The magic happens in line 17, 18 and 19, where I add something…

Contents