CS计算机代考程序代写 # Lecture 8 Analysis (Part 2)

# Lecture 8 Analysis (Part 2)
# Author: Chris Hansman
# Email: chansman@imperial.ac.uk
# 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 Plot plot <- ggplot(lifedata, aes(x = gdpPercap, y=lifeExp)) + geom_point() plot # A little Nicer plot <- 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 Animation plot <- plot + transition_time(year) + labs(title = "Year: {frame_time}") animate(plot, renderer = gifski_renderer()) # Splitting BY continent plot_continent <- plot + facet_wrap(~continent) animate(plot_continent, renderer = gifski_renderer()) # Adding wake plot_wake <- plot + shadow_wake(wake_length = 0.1, alpha = FALSE) animate(plot_wake, renderer = gifski_renderer())

Leave a Reply

Your email address will not be published. Required fields are marked *