# Lecture 8 Analysis (Part 2)
# Author: Chris Hansman
# Email: [email protected]
# Date : 01/03/21
# Installing Packages
install.packages(gifski)
install.packages(gganimate)
install.packages(gapminder)
# Loading Libraries
library(tidyverse)
library(gganimate)
library(gifski)
library(gapminder)
# Setting graph theme
theme_set(theme_classic())
#-
# Part 2: Animating Plots
#-
# Loading Data
lifedata<-gapminder# Simple Scatter Plotplot <- ggplot(lifedata, aes(x = gdpPercap, y=lifeExp)) +geom_point()plot# A little Nicerplot <- ggplot(gapminder, aes(x = gdpPercap,size = pop, y=lifeExp, colour=country)) +geom_point(show.legend=FALSE, alpha = 0.7) +scale_size(range = c(2, 12)) +scale_x_log10()+labs(x = “GDP per capita”, y = “Life expectancy”)plot# Adding Animationplot <- plot + transition_time(year) +labs(title = “Year: {frame_time}”) animate(plot, renderer = gifski_renderer())# Splitting BY continentplot_continent <- plot + facet_wrap(~continent)animate(plot_continent, renderer = gifski_renderer())# Addingwakeplot_wake <- plot + shadow_wake(wake_length = 0.1, alpha = FALSE)animate(plot_wake, renderer = gifski_renderer())
Reviews
There are no reviews yet.