To create a one-page report that summarises the relationship between certain socio-demographic variables and EU referendum voting patterns. You can find an example report here.
tidyverse packagevariables.csv file which contains socio-demographic data and a census code for each Local Authority area. The data derive from the 2011 Census via the UK Data Service and the Annual Survey of Hours and Earnings (2016) by Local Authority area.There are 7 different variables:
degree: % residents with higher educationpay: median gross annual pay (full time)percent_aged_18_30: % residents aged 18-30 yearsmedian_age: Median age of residentsnon_uk: % residents not born in the UKno_passport: % of residents without a passportABC1: % residents in professional occupationsreferendum data frame to only include the following columns:
Area_CodeAreaElectoratePct_RemainPct_Leavereferendum data frame to exclude “Northern Ireland” and “Gibraltar”. We have no socio-demographic data for these areas.referendum data frame called Result which records the outcome of the vote in each Local Authority area. Tip: use an ifelse() statement.Area_Code in the variables data frame into a factor.degree and percent_aged_18_30 in the variables data frame into percentages.variables data frame with the referendum data frame.ggplot2 package showing the relationship between the share of the Leave vote with the percentage of residents having a degree.plotly R package to make your scatterplot interactive.knit your R Markdown document to HTML.