2nd Project

sBREXIT RESULT ANALYSIS

This project is done to analyse the brexit vote.

library(tidyverse)  # Load ggplot2, dplyr, and all the other tidyverse packages
library(gapminder)  # gapminder dataset
library(readr)
library(ggplot2) 
library(here)
library(janitor)
library(htmltools)
library(stringi)
brexit_results <- read_csv(here::here("data","brexit_results.csv"))
## Rows: 632 Columns: 11
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (1): Seat
## dbl (10): con_2015, lab_2015, ld_2015, ukip_2015, leave_share, born_in_uk, m...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
glimpse(brexit_results)
## Rows: 632
## Columns: 11
## $ Seat        <chr> "Aldershot", "Aldridge-Brownhills", "Altrincham and Sale W…
## $ con_2015    <dbl> 50.592, 52.050, 52.994, 43.979, 60.788, 22.418, 52.454, 22…
## $ lab_2015    <dbl> 18.333, 22.369, 26.686, 34.781, 11.197, 41.022, 18.441, 49…
## $ ld_2015     <dbl> 8.824, 3.367, 8.383, 2.975, 7.192, 14.828, 5.984, 2.423, 1…
## $ ukip_2015   <dbl> 17.867, 19.624, 8.011, 15.887, 14.438, 21.409, 18.821, 21.…
## $ leave_share <dbl> 57.89777, 67.79635, 38.58780, 65.29912, 49.70111, 70.47289…
## $ born_in_uk  <dbl> 83.10464, 96.12207, 90.48566, 97.30437, 93.33793, 96.96214…
## $ male        <dbl> 49.89896, 48.92951, 48.90621, 49.21657, 48.00189, 49.17185…
## $ unemployed  <dbl> 3.637000, 4.553607, 3.039963, 4.261173, 2.468100, 4.742731…
## $ degree      <dbl> 13.870661, 9.974114, 28.600135, 9.336294, 18.775591, 6.085…
## $ age_18to24  <dbl> 9.406093, 7.325850, 6.437453, 7.747801, 5.734730, 8.209863…
brexit_histogram <- ggplot(brexit_results, aes(x = leave_share)) +
  geom_histogram(binwidth = 2.5)

brexit_histogram <- brexit_histogram +
labs(title = "Brexit Leave Share",
     x = "leave share") +
NULL

brexit_density_plot <- ggplot(brexit_results, aes(x = leave_share)) +
  geom_density()
brexit_density_plot<- brexit_density_plot +
  labs(title = "Brexit Density Plot",
       x = "Leave Share") +
  NULL


brexit_cum_dis <- ggplot(brexit_results, aes(x = leave_share)) +
  stat_ecdf(geom = "step", pad = FALSE) +
  scale_y_continuous(labels = scales::percent)
brexit_cum_dis <- brexit_cum_dis +
  labs(title = "Brexit Cummulative Distribution",
       x = "leave Share")+
  NULL
 brexit_results %>% 
  select(leave_share, born_in_uk) %>% 
  cor()
##             leave_share born_in_uk
## leave_share   1.0000000  0.4934295
## born_in_uk    0.4934295  1.0000000
brexit_immigration_plot <- ggplot(brexit_results, aes(x = born_in_uk, y = leave_share)) +
  geom_point(alpha=0.3) +
  

  geom_smooth(method = "lm") + 
  

  theme_bw() +
  NULL
brexit_immigration_plot <- brexit_immigration_plot +
  labs(title = "Correlation Between native residents and their leave share",
       x = "born in UK",
       y = "leave share") +
  NULL

The correlation is almost 0.5, which shows that the two variables are positively correlated.

Looking at the graphs and plots, we can say there is positive correlation between people born in Uk and its leave share. Graph implies about 50% of the native residents were supporting Brexit. There might be a possibility people in areas where migration rate is low have higher proportion of leave voters compared to areas with high migration rate. So, immigration could be a major factor impacting the brexit result.