Build Status License: CC BY 4.0

English | 简体中文

knitr::opts_chunk$set(
  fig.path = "man/figures/",
  message = FALSE
)

Data source

Installation

if (!require(remotes)) install.packages("remotes")
if (!require(ncovmap)) remotes::install_github("yiluheihei/ncovmap")

Feature:

library(ncovmap)
library(leafletCN)
library(magrittr) # for pipe

How to use

Data retrieve

# latest data
ncov <- get_ncov2(method = "api")
# ncov class inherit from data.frame
ncov
data.frame(ncov) %>%
  head()

Data subset

# 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()

china map

plot_china_map(china, legend_position = "bottomleft")

province map of china

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)
)

world map

plot_world_map(world, legend_position = "bottomleft")

korea map

korea_ncov <- get_foreign_ncov("韩国")
plot_foreign_map(korea_ncov, "korea")

japan map

jp_ncov <- get_foreign_ncov("日本")
plot_foreign_map(jp_ncov, "japan")

iran map

iran_ncov <- get_foreign_ncov("伊朗")
plot_foreign_map(iran_ncov, "iran")

italy map

italy_ncov <- get_foreign_ncov("意大利")
plot_foreign_map(italy_ncov, "italy")

plot multiple maps

## 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)
))

Acknowlegement



yiluheihei/ncovmap documentation built on March 30, 2020, 5:27 a.m.