Historical Phones

Joining tables, Animated world choropleth, Adding IQR to geom_line, World development indicators package

Published

November 9, 2020

Notable topics: Joining tables, Animated world choropleth, Adding IQR to geom_line, World development indicators package

Recorded on: 2020-11-09

Timestamps by: Eric Fletcher

View code

Screencast

Timestamps

bind_rows
dplyr

Use bind_rows from the dplyr package to combine the two data sets.

ggplotgroup
ggplot2

Use group = interaction(type, country) within ggplot aes() to set the interaction type with every single country on one plot.

semi_jointop_n
dplyr

Use semi_join from the dplyr package to join rows from phones with a match in country_sizes.

quantilegeom_ribbon
statsggplot2

Use quantile from the stats package within summarize to show the 25th, and 75th quantiles (interquartile range) on the plot.

WDIselect
WDIdplyr

Import the wdi package (World Development Indicators from the World Bank) with extra = TRUE in order to get the iso3c code and income level for each country.

inner_join
dplyr

Use inner_join from the dplyr package to join the WDI data with the phones data.

fct_relevel
forcats

Use fct_relevel from the forcats package to reorder income factor levels in ascending order.

.

Create an anonymous function using . (dot).

inner_joingeom_abline
dplyrggplot2

Use inner_join from the dplyr package to join the mobile data and landline data together with a geom_abline to see how different the total populations are between the two datasets.

geom_hline
ggplot2

Use geom_hline to add a refrence line to the plot shwoing when each country crossed the 50 per 100 subscription mark.

summarizemin
dplyr

Use summarize from the dplyr package with min(year([Mobile >= 50])) to find the year in which each country crossed the 50 per 100 subscription mark.

summarizemax
dplyr

Use summarize from the dplyr package with max(Mobile) to find the peak number of mobile subscriptions per country.

na_ifsummarize
dplyr

Use na_if from the dplyr package within summarize to change Inf to NA.

WDIsearch
WDI

Using the WDIsearch function to search the WDI package for proper GDP per capita indicator. Ended up using the NY.GDP.PCAP.PP.KD indicator.

WDIselect
WDIdplyr

Adding the GDP data from the WDI package to the country_incomes table.

inner_join
dplyr

Using the inner_join function from the dplyr package to join the phones table with the country_incomes table pulling in the gdp_per_capita variable.

WDIsearch
WDI

Using the WDIsearch function to search the WDI package for proper population indicator. Ended up using the SP.POP.TOTL indicator.

map_dataiso3166regex_left_joinleft_jointransition_manual
mapsggplot2fuzzyjoingganimate

Create an animated choropleth world map with fill = subscriptions.

Summary of screencast