-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.zh.Rmd
144 lines (107 loc) · 2.82 KB
/
README.zh.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
---
title: "ncov 2019"
date: "`r format(Sys.time(), '%Y年%m月%d日')`"
output:
- github_document
---
[![Build Status](https://travis-ci.com/yiluheihei/ncovmap.svg?branch=master)](https://travis-ci.com/yiluheihei/ncovmap)
[![License: CC BY 4.0](https://img.shields.io/badge/License-CC%20BY%204.0-lightgrey.svg)](https://creativecommons.org/licenses/by/4.0/)
简体中文 | [English](README.md)
```{r set}
knitr::opts_chunk$set(
fig.path = "man/figures/",
message = FALSE
)
```
ncov 疫情图,参考[ncovr](https://github.com/pzhaonet/ncovr), 具体使用详情见[vignette](https://yiluheihei.github.io/ncovmap/articles/Introduction.html). 暂放于此,后续可并入[ncovr](https://github.com/pzhaonet/ncovr)
## 数据来源
数据获取通过[DXY-COVID-19-Crawler](https://github.com/BlankerL/DXY-COVID-19-Crawler)
api 下载,调用`get_ncov()`即可获取。
## 安装
```{r eval=FALSE}
if (!require(remotes)) install.packages("remotes")
if (!require(ncovmap)) remotes::install_github("yiluheihei/ncovmap")
```
```{r load-ncovmap,message=FALSE}
library(ncovmap)
library(leafletCN)
```
## 下载ncov数据
```{r data, message=FALSE}
ncov <- get_ncov2(method = "api")
ncov
```
## 提取省市或国家数据
```{r subset}
# 中国数据
china <- ncov['china']
china
# 省市数据
hubei <- ncov['湖北省']
hubei
beijing <- ncov['北京市']
beijing
beijing$cities
# 世界数据
world <- ncov['world']
world
```
## 国内总体疫情图
```{r china-map}
plot_china_map(china, legend_position = "bottomleft")
```
## 省份疫情图
湖北省
```{r hubei-map}
plot_province_map(
hubei,
"湖北省",
bins = c(0, 100, 200, 500, 1000, 10000)
)
```
北京市
```{r beijing-map}
plot_province_map(
beijing,
"北京市",
bins = c(0, 10, 50, 100)
)
```
## 世界整体疫情图
```{r world-map}
plot_world_map(world, legend_position = "bottomleft")
```
## 国外疫情图
### 韩国疫情图
```{r korea-map}
korea_ncov <- get_foreign_ncov("韩国")
plot_foreign_map(korea_ncov, "korea")
```
### 日本疫情图
```{r jp-map}
jp_ncov <- get_foreign_ncov("日本")
plot_foreign_map(jp_ncov, "japan")
```
### 伊朗疫情图
```{r iran-map}
iran_ncov <- get_foreign_ncov("伊朗")
plot_foreign_map(iran_ncov, "iran")
```
### 意大利疫情图
```{r italy-map}
italy_ncov <- get_foreign_ncov("意大利")
plot_foreign_map(italy_ncov, "italy")
```
### 直接画这四个国家的疫情图
```{r four-country-map,eval=FALSE}
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)
))
```
## 致谢
谢谢BlankerL的提供[API](https://github.com/BlankerL/DXY-COVID-19-Crawler)和
[数据仓库](https://github.com/BlankerL/DXY-COVID-19-Data)