Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2022
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1.  
  2. #Clear Objects
  3. rm(list = ls())
  4.  
  5. #Set Working Directory
  6. setwd("C:/Users/roger/OneDrive - The University of Nottingham/Political Data/v11")
  7.  
  8. #Install Packages (*un-comment if needed*)
  9. #install.packages("tidyverse")
  10. #install.packages("patchwork")
  11.  
  12. #Load Packages
  13. library(tidyverse)
  14. library(patchwork)
  15.  
  16. #Load in our shapefile
  17. world_map <- map_data("world")
  18.  
  19. #Read Data Set
  20. full_covid_data <- read.csv("JHU-UN-IPU_Covid.csv")
  21.  
  22. full_covid_data
  23. #Filter Data Set
  24. covid <- filter(full_covid_data, monthlyDateN == c(2021.09,2020.06))
  25.  
  26. #Merge variables of interest
  27. covidmap <- left_join(world_map, covid, by = c(region = "country"))
  28.  
  29. covidmap2 <- filter(covidmap, total_cases != 0 )
  30.  
  31. map <- ggplot() + geom_polygon(data = covidmap2, color = "black", size = 0.25,
  32. aes(x = long, y = lat, group = group, fill = (death/total_cases)))
  33.  
  34. map + geom_path() + scale_fill_gradient(low = "blue", high = "red") +
  35. theme(axis.text.x = element_blank(), axis.text.y = element_blank(), axis.ticks = element_blank()) +
  36. labs(title = "Lethality of COVID", fill = "Deaths / cases", x = "", y = "") +
  37. theme(panel.background = element_blank()) + facet_wrap(~monthlyDateN)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement