【R】Asiaの地図を表示
2020年12月13日
アジアの地図を表示してみます。データは、rnaturalearthで取得。人口別のコロプレス図にします。こちらのサイトを参考にしました。
library(rnaturalearth) library(ggplot2) library(ggrepel) library(tidyverse) library(sf) library(kableExtra) asia <- rnaturalearth::ne_countries( continent = "Asia", returnclass = "sf" ) dat <- asia %>% mutate( centroid = st_centroid(geometry), x = st_coordinates(centroid)[, 1], y = st_coordinates(centroid)[, 2] ) %>% arrange(desc(pop_est)) ggplot(dat, aes(fill = pop_est)) + geom_sf() + scale_fill_viridis_c() + theme_void() + geom_text_repel(aes(x = x, y = y, label = name), col="skyblue", size = 4) table_df<-data.frame(Country=dat$name, Population=dat$pop_est) library(clipr) table_df %>% kable(align = "c", row.names=FALSE) %>% kable_styling(full_width = F) %>% column_spec(1, bold = T) %>% collapse_rows(columns = 1, valign = "middle") %>% write_clip
Country | Population |
---|---|
China | 1338612970 |
India | 1166079220 |
Indonesia | 240271522 |
Pakistan | 176242949 |
Bangladesh | 156050883 |
Japan | 127078679 |
Philippines | 97976603 |
Vietnam | 86967524 |
Turkey | 76805524 |
Iran | 66429284 |
Thailand | 65905410 |
Korea | 48508972 |
Myanmar | 48137741 |
Iraq | 31129225 |
Saudi Arabia | 28686633 |
Nepal | 28563377 |
Afghanistan | 28400000 |
Uzbekistan | 27606007 |
Malaysia | 25715819 |
Yemen | 23822783 |
Taiwan | 22974347 |
Dem. Rep. Korea | 22665345 |
Sri Lanka | 21324791 |
Syria | 20178485 |
Kazakhstan | 15399437 |
Cambodia | 14494293 |
Azerbaijan | 8238672 |
Tajikistan | 7349145 |
Israel | 7233701 |
Lao PDR | 6834942 |
Jordan | 6342948 |
Kyrgyzstan | 5431747 |
Turkmenistan | 4884887 |
United Arab Emirates | 4798491 |
Georgia | 4615807 |
Palestine | 4119083 |
Lebanon | 4017095 |
Oman | 3418085 |
Mongolia | 3041142 |
Armenia | 2967004 |
Kuwait | 2691158 |
Timor-Leste | 1131612 |
Qatar | 833285 |
Bhutan | 691141 |
Cyprus | 531640 |
Brunei | 388190 |
N. Cyprus | 265100 |