get_korea_regional_cases.Rd
Extract regional case counts for South Korea. Source.
get_korea_regional_cases()
if (FALSE) { # Mapping data <- get_korea_regional_cases() regions <- rnaturalearth::ne_states("South Korea", returnclass = "sf") regions_with_data <- regions %>% mutate(name_de = str_replace_all(name_de, "Jeju-do", "Jeju")) %>% left_join(data, by = c("name_de" = "region")) ggplot(regions_with_data) + geom_sf(aes(fill = cases)) } get_korea_regional_cases#> function () #> { #> webpage <- xml2::read_html("http://ncov.mohw.go.kr/en/bdBoardList.do?brdId=16&brdGubun=162&dataGubun=&ncvContSeq=&contSeq=&board_id=") #> ch <- memoise::cache_filesystem(".cache") #> mem_read <- memoise::memoise(xml2::read_html, cache = ch) #> region <- webpage %>% rvest::html_nodes("tbody tr+ tr th") %>% #> rvest::html_text() #> cases <- webpage %>% rvest::html_nodes("tr+ tr th+ .number") %>% #> rvest::html_text() #> cases <- cbind(region, cases) #> cases <- tibble::as_tibble(cases) %>% dplyr::filter(region != #> "Lazaretto") %>% dplyr::mutate(cases = as.numeric(as.character(cases))) #> return(cases) #> } #> <bytecode: 0x7ff8eb99c4b0> #> <environment: namespace:NCoVUtils>