get_uk_nhs_region_cases.Rd
Get UK regional cases.
get_uk_nhs_region_cases()
A dataframe of case counts in English NHS regions
get_uk_nhs_region_cases#> function () #> { #> warning("The soource data for this function is no longer updated. Try get_uk_regional_cases for similar data") #> path <- "https://raw.githubusercontent.com/emmadoughty/Daily_COVID-19/8a0ea87f40edf746519afdb4d1e7ed95c816df1e/Data/COVID19_cum.csv" #> cases <- readr::read_csv(file = path) #> locations <- c("London", "South East", "South West", "East of England", #> "Midlands", "North East and Yorkshire", "North West", #> "Ayrshire and Arran", "Borders", "Dumfries and Galloway", #> "Fife", "Forth Valley", "Grampian", "Greater Glasgow and Clyde", #> "Highland", "Lanarkshire", "Lothian", "Shetland", "Tayside", #> "Wales", "Northern Ireland", "Orkney", "Western Isles") #> cases_nhs <- cases %>% dplyr::mutate(date = stringr::str_replace_all(Date, #> pattern = "\\.", replacement = "/")) %>% dplyr::select(-Date) %>% #> tidyr::gather("UTLA", "confirm", -date) %>% tidyr::drop_na(date, #> confirm) %>% dplyr::mutate(UTLA = stringr::str_replace_all(UTLA, #> "_", " "), confirm = confirm %>% stringr::str_squish() %>% #> as.numeric) %>% dplyr::filter(UTLA %in% c("London", "South East", #> "South West", "East of England", "Midlands", "North East and Yorkshire", #> "North West", "Ayrshire and Arran", "Borders", "Dumfries and Gallow", #> "Fife", "Forth Valley", "Grampian", "Greater Glasgow and Clyde", #> "Highlands", "Lanarkshire", "Lothian", "Shetland", "Tayside", #> "Wales", "Northern Ireland")) %>% dplyr::mutate(UTLA = dplyr::recode(UTLA, #> `Dumfries and Gallow` = "Dumfries and Galloway", Highlands = "Highland"), #> date = lubridate::dmy(date)) %>% tidyr::complete(UTLA = locations, #> date = seq(min(date), max(date), by = "day")) %>% dplyr::mutate(confirm = tidyr::replace_na(confirm, #> 0)) #> cases_nhs <- cases_nhs %>% dplyr::select(region = UTLA, total_cases = confirm, #> date) %>% dplyr::arrange(date) %>% dplyr::group_by(region) %>% #> dplyr::mutate(index = 1:dplyr::n(), cases = total_cases - #> ifelse(index == 1, 0, dplyr::lag(total_cases))) %>% #> dplyr::ungroup() %>% dplyr::select(-index, -total_cases) %>% #> dplyr::mutate(cases = ifelse(cases < 0, 0, cases)) #> return(cases_nhs) #> } #> <bytecode: 0x7ff8ebcb9240> #> <environment: namespace:NCoVUtils>if (FALSE) { uk_shp <- readRDS("uk_shp.rds") cases <- NCoVUtils::get_uk_regional_cases() cases <- cases[1:23,] uk_shp %>% dplyr::full_join(cases, by = "region") %>% ggplot2::ggplot(ggplot2::aes(fill = cases)) + ggplot2::geom_sf() }