Appendix D — Exercise 6 solutions

D.1 Question

Combine all three OBR datasets (housing market, labour market and living wage) together to create one complete dataset, obr_data.

Solution

Use full_join to combine the housing and labour market data by year and quarter, then pipe to apply full_join to the resulting data and add the living wage, joining by year. As there are multiple year rows in the housing and labour market data, include the argument muliple = "all" to ensure the living wage variable is repeated for each quarter.

# full join the housing and labour market data
obr_data <- full_join(housing_market, labour_market, 
                      by = c("year", "quarter")) %>% 
  # join this data to the living wage
  full_join(., living_wage_long, by = "year", multiple = "all")