Big Mac Index

Data manipulation, Pairwise correlation

Notable topics: Data manipulation, Pairwise correlation

Recorded on: 2020-12-21

Timestamps by: Eric Fletcher

## Screencast

## Timestamps

Use the `add_count`

function from the `dplyr`

package with `name = "country_total"`

to count the number of observations by group in the `name`

variable.

Use `filter`

from the `dplyr`

package with `country_total == max(country_total)`

to filter the data for countries where every data point is provided.

Use the `rename`

function from the `dplyr`

package to rename the `name`

variable to `country_name`

.

Use `theme(legend.position = "none")`

to hide the legend generated by the `geom_line`

plot.

Use the `expand_limits`

function from the `ggplot2`

package with `y = 0`

so that each `facet panel`

has a y-axis that starts at the same point, in this case 0.

Reorder `facet panels`

using the `fct_reorder`

from the `forcats`

package with a function passed in to the `.fun`

argument to calculate the ratio between `max`

and `min`

values in the `local_price`

variable. At 12:00, David changes from using `max`

and `min`

to `last`

and `first`

to calculate the `Big Mac inflation rate`

.

Use `scale_x_log10`

from the `ggplot2`

package to change the `breaks`

for the `x-axis`

while also applying a `log10`

tranformation.

Use `geom_text`

from the from the `ggplot2`

with `paste0`

package to add labels to each bar in the plot indicating how many time `X`

the price of a Big Mac increased from 2000 to 2020.

Add two lines to a plot using 2 `geom_line`

with `color =`

argument and `y=`

argument to distinguish between the two lines.

Use `geom_hline`

from the `ggplot2`

package to add horizontal reference line to each facet panel.

Use `theme`

from the `ggplot2`

package with `axis.text.x = element_text(angle = 90, hjust = 1)`

to rmake the x-axis labels horizontal in order to avoid overcrowding.

Use `geom_text`

to add country names to each point in `geom_point`

plot. David then opts to use `geom_text_repel`

from the `ggrepel`

package instead to avoid overcrowding.

Use `geom_smooth`

from the `ggplot2`

package with `lm`

smoothing method to help show the linear trend when comparing `gdp_dollar`

to `usd_raw`

.

Use the `gganimate`

package to animate the `GDP per capital`

versus `adjusted big mac index relative to USD`

over time.

Use `str_to_upper`

and `str_remove`

to remove `_adjusted`

from `base_currency`

while uppercasing the characters that remain.

Use `pairwise_cor`

from the `widyr`

package to perform `pairwise correlation`

to figure out which countries Big Mac prices tend to move together over time.

Screencast summary.