Appendix E — Exercise 6 solutions

E.1 Question

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

Solution

Use full_join to combine the housing and disposable 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 disposable income 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, disposable_income, 
                      by = c("year", "quarter")) %>% 
  # join this data to the living wage
  full_join(., living_wage_long, by = "year", multiple = "all")