"High fatality accidents in United Kingdom"
  • AI Chat
  • Code
  • Report
  • Beta
    Spinner

    "High fatality accidents in United Kingdom in 2020"

    Introduction:

    In this project, we want to study road safety in more detail in order to reduce the number of serious accidents. We will classify serious accidents as fatal accidents in which more then 3 people were injured. We will try to learn more about the characteristics of these serious accidents in order to reduce the number of deaths.

    Published by the department for transport. https://data.gov.uk/dataset/road-accidents-safety-data Contains public sector information licensed under the Open Government Licence v3.0.

    In this project we will answer the questions:

    1. What time of day and day of the week do most serious accidents happen?
    2. Are there any patterns in the time of day/ day of the week when serious accidents occur?
    3. What characteristics stand out in serious accidents compared with other accidents?
    4. On what areas would you recommend the planning team focus their brainstorming efforts to reduce serious accidents?

    1. What time of day and day of the week do most serious accidents happen?

    The road safety team within the department of transport collected for us a number of data on the basis of which we will conduct an analysis.

    install.packages("plyr")
    install.packages("ggplot2")
    install.packages("ggrepel")
    install.packages("lubridate")
    install.packages("ggjoy")
    install.packages("ggmap")
    install.packages("maps")
    install.packages("mapdata")
    install.packages("mapproj")
    install.packages("ggridges")
    install.packages("ggthemes")
    install.packages("viridis")
    
    library(plyr)
    library(ggjoy)
    library(ggrepel)
    library(mapproj)
    library(ggmap)
    library(maps)
    library(mapdata)
    library(tidyr)
    library(ggplot2)
    library(stringr)
    library(lubridate)
    library(ggthemes)
    library(viridis)
    library(ggridges)
    library(readr)
    library(tidyverse)
    library(tidyverse)
    accidents <- readr::read_csv('./data/accident-data.csv')
    head(accidents)
    lookup <- readr::read_csv('./data/road-safety-lookups.csv')
    head(lookup)

    For a better visualization, we provide a map on which all big cities of the United Kingdom are represented.

    UK <- map_data("world") %>%
    filter(region =="UK") 
    data <- world.cities %>% 
    filter(country.etc=="UK")
    City <-ggplot() +
      geom_polygon(data = UK, aes(x=long, y = lat, group = group), fill="grey", alpha= 0.5) +
      geom_point( data=data, aes(x=long, y=lat, alpha=pop)) +
      geom_text_repel( data=data %>% arrange(pop) %>% tail(10), aes(x=long, y=lat, label=name), size=6) +
      geom_point( data=data %>% arrange(pop) %>% tail(10), aes(x=long, y=lat), color="red", size=3) +
      theme_void() + ylim(50,59) + coord_map() +
      theme(legend.position="none") +
      labs(title = "UNITED KINGDOM MAP") 
    
    
    City

    Also on this map we can see the concentration of road accidents.

    UK_map_data <- map_data("world", c('UK', 'Isle of Man','Isle of Wight', 'Wales:Anglesey'))
    map <- ggplot() + 
      geom_polygon(data = UK_map_data, aes( x=long,y = lat,group= group), colour = alpha("black", 1/4), fill = NA) +
      geom_point(data = accidents, aes(x=longitude, y=latitude, group = accident_index), alpha=0.05, size=0.2, col="red") +
      ggtitle("United Kingdom Traffic Accidents 
                         in 2020") +
      coord_map("albers", lat0=49.84, lat1=60.85) +
      theme_classic() +
      theme(panel.border = element_blank(),
            axis.text = element_blank(),
            line = element_blank(),
            axis.title = element_blank(),
            plot.title = element_text(size=17, face="bold"))
    
    map