English | 简体中文
knitr::opts_chunk$set( fig.path = "man/figures/", message = FALSE )
if (!require(remotes)) install.packages("remotes") if (!require(ncovmap)) remotes::install_github("yiluheihei/ncovmap")
Feature:
get_ncov2()
: retrieve latest or time-series data of covid-2019 plot_china_map()
: plot on china mapplot_province_map()
: plot on province map of chinaplot_world_map()
: plot on world mapplot_foreign_map()
: plot on japan, korea, italy or iran maplibrary(ncovmap) library(leafletCN) library(magrittr) # for pipe
# latest data ncov <- get_ncov2(method = "api") # ncov class inherit from data.frame ncov data.frame(ncov) %>% head()
# china data china <- ncov['china'] china # Hubei province of china hubei <- ncov['Hubei'] hubei # Beijing beijing <- ncov['Beijing'] # world data world <- ncov['world'] world data.frame(world) %>% head()
plot_china_map(china, legend_position = "bottomleft")
Hubei province
plot_province_map( hubei, "Hubei", bins = c(0, 100, 200, 500, 1000, 10000) )
Beijing
plot_province_map( beijing, "Beijing", bins = c(0, 10, 50, 100) )
plot_world_map(world, legend_position = "bottomleft")
korea_ncov <- get_foreign_ncov("韩国") plot_foreign_map(korea_ncov, "korea")
jp_ncov <- get_foreign_ncov("日本") plot_foreign_map(jp_ncov, "japan")
iran_ncov <- get_foreign_ncov("伊朗") plot_foreign_map(iran_ncov, "iran")
italy_ncov <- get_foreign_ncov("意大利") plot_foreign_map(italy_ncov, "italy")
## not run foreign_countries <- c("韩国", "伊朗", "日本", "意大利") names(foreign_countries) <- c("korea", "iran", "japan", "italy") htmltools::tagList(purrr::imap( foreign_countries, ~ get_foreign_ncov(.x) %>% plot_foreign_map(.y) ))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.