Skip to content

Instantly share code, notes, and snippets.

@kenjisato
Last active October 16, 2019 07:03
Show Gist options
  • Save kenjisato/8e1d93d89b41356accfa353e0670dd5b to your computer and use it in GitHub Desktop.
Save kenjisato/8e1d93d89b41356accfa353e0670dd5b to your computer and use it in GitHub Desktop.
library(dplyr)
library(sf)
library(tmap)
library(rmapshaper)
#' Install googlesheets4 with
#' remotes::install_github("tidyverse/googlesheets4")
#' devtools::install_github("tidyverse/googlesheets4")
library(googlesheets4)
gdp <- read_sheet("1FPCYqMy-jBqhWTNrT9jrnt2xFds65FomzbjxraxGv3Q")
gdp <- gdp %>%
select(Provinces, `GDP (CN¥)`) %>%
filter(Provinces != "Mainland China")
#' Download Shapefile from
#' https://gadm.org/download_country_v3.html
china0 <- st_read("./Data/gadm36_CHN_shp/gadm36_CHN_1.shp")
china0 <- ms_simplify(china0)
china <- china0 %>%
select(name = NAME_1,
chname = NL_NAME_1) %>%
mutate(name = as.character(name),
chname = sub(".*\\|(.*)", "\\1", chname))
china$chname[[11]] <- "黑龙江省"
china <- china %>%
left_join(gdp, by = c("name" = "Provinces"))
tm_shape(china) +
tm_polygons("GDP (CN¥)") +
tm_text("chname", fontfamily = "Hei")
Provinces GDP (CN¥) Nominal GDP (US$) PPP GDP (Int'l. $) real real growth (%) Share (%) Population
Mainland China 90,030,950 13,605,185 25,648,448 6.6 100
Guangdong 9,727,777 1,470,030 2,771,289 6.8 10.8
Jiangsu 9,259,540 1,399,272 2,637,895 6.7 10.28
Shandong 7,646,967 1,155,585 2,178,499 6.4 8.49
Zhejiang 5,619,715 849,233 1,600,967 7.1 6.24
Henan 4,805,586 726,205 1,369,035 7.6 5.34
Sichuan 4,067,813 614,715 1,158,855 8 4.52
Hubei 3,936,655 594,895 1,121,490 7.8 4.37
Hunan 3,642,578 550,455 1,037,712 7.8 4.05
Hebei 3,601,027 544,176 1,025,875 6.6 4
Fujian 3,580,404 541,059 1,020,000 8.3 3.98
Shanghai 3,267,987 493,848 930,997 6.6 3.63
Beijing 3,031,998 458,186 863,768 6.6 3.37
Anhui 3,000,682 453,453 854,846 8 3.33
Liaoning 2,531,535 382,557 721,194 5.7 2.81
Shaanxi 2,443,832 369,304 696,209 8.3 2.71
Jiangxi 2,198,478 332,227 626,311 8.7 2.44
Chongqing 2,036,319 307,722 580,115 6 2.26
Guangxi 2,035,251 307,561 579,811 6.8 2.26
Tianjin 1,880,964 284,245 535,857 3.6 2.09
Yunnan 1,788,112 270,214 509,405 8.9 1.99
Nei Mongol 1,728,922 261,269 492,542 5.3 1.92
Shanxi 1,681,811 254,150 479,121 6.7 1.87
Heilongjiang 1,636,162 247,251 466,116 4.7 1.82
Jilin 1,507,462 227,803 429,452 4.5 1.67
Guizhou 1,480,645 223,750 421,812 9.1 1.64
Xinjiang Uygur 1,219,908 184,349 347,532 6.1 1.35
Gansu 824,607 124,612 234,917 6.3 0.92
Hainan 483,205 73,020 137,657 5.8 0.54
Ningxia Hui 370,518 55,991 105,555 7 0.41
Qinghai 286,523 43,298 81,626 7.2 0.32
Xizang 147,763 22,329 42,095 9.1 0.16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment