Two methods of creating a slope plot in R with ggplot2 (CC146)
A slope plot (or slope chart) is an effective visualization tool to compare the change in something between two time points. In this Code Club, Pat uses the ggplot2 R package to show two methods of generating a slope plot: using geom_segmet and geom_line. The data is taken from an Ipsos survey that found the percentage of people in 15 countries who said they were willing to receive the COVID-19 vaccine as of August and October of 2020.
Pat uses functions from the tidyverse including the geom_line
and geom_segment
functions from the ggplot2
package and the dplyr
package in #RStudio.
Code
You can browse the state of the repository at the
Data
The august_october_2020.csv
data is available in the GitHub repository.
X.1,Total Agree - August 2020,Total Agree - October 2020
Total,77,73
India,87,87
China,97,85
South Korea,84,83
Brazil,88,81
Australia,88,79
United Kingdom,85,79
Mexico,75,78
Canada,76,76
Germany,67,69
Japan,75,69
South Africa,64,68
Italy,67,65
Spain,72,64
United States,67,64
France,59,54