参考https://mp.weixin.qq.com/s/bPXdOGFzFK5dWLTEOEJB3g
安装,
如果失败,不同时间点重复一下
remotes::install_github("GuangchuangYu/nCov2019")
remotes::install_github("GuangchuangYu/chinamap",force = TRUE)
require(nCov2019)
require(chinamap)
中文版
x = get_nCov2019()
cn = get_map_china()
plot(x, region='china', chinamap=cn,
continuous_scale=FALSE,
font.size=3)
英文版
x = get_nCov2019(lang='en')
cn = get_map_china()
cn$province <- trans_province(cn$province)
plot(x, region='china', chinamap=cn,
continuous_scale=FALSE,
font.size=2)

画某一个省
中文版
m = sf::st_read("./china-city-map/市界.shp")
plot(x, region='山西', chinamap=m)

英文版
x = get_nCov2019(lang='en')
m = sf::st_read("./china-city-map/市界.shp")
map <- tibble::as_tibble(m)
map$NAME <- trans_city(map$NAME)
plot(x, region='Hubei', chinamap=map)

不知道为什么,英文版只能画湖北的
library(export)
graph2ppt(file="Rplot", width=7, height=5)
中间遇到的问题:
问题一:
载入chinamap包时:
require(chinamap)
载入需要的程辑包:chinamap
载入程辑包:‘chinamap’
The following object is masked _by_ ‘.GlobalEnv’:
get_map_china
获取中国地图时:
cn = get_map_china()
Error in get("china", envir = .GlobalEnv) : object 'china' not found
解决方法:删除文件下的.RData文件。
问题二:
打开导出的ppt后,出现:解决方法:设置graph2ppt导出参数时,width ≥ 10, height ≥ 9。
网友评论