OkBublewrap

세계지도 본문

R/학습용

세계지도

옥뽁뽁 2021. 6. 25. 01:23
# 패키지
install.packages("maps")
library(maps)
install.packages("ggplot2")
library(ggplot2)
world_map <- map_data("world")  # 내장데이터 
str(world_map)

 $ long     : num  -69.9 -69.9 -69.9 -70 -70.1 ...
 $ lat      : num  12.5 12.4 12.4 12.5 12.5 ...
 $ group    : num  1 1 1 1 1 1 1 1 1 1 ...
 $ order    : int  1 2 3 4 5 6 7 8 9 10 ...
 $ region   : chr  "Aruba" "Aruba" "Aruba" "Aruba" ...
 $ subregion: chr  NA NA NA NA ...

 

ggplot(world_map, aes(x=long, y=lat, group=group)) + geom_path() 
ggplot(world_map, aes(x=long, y=lat, group=group, fill=region)) +    
            geom_polygon(colour="black", size=0.1) +   
            theme(legend.position="none")

x = longitude , y = latitude

세계지도

east_asia <- map_data("world", region=c("North Korea", "South Korea", "China", 
                                       "Japan"))
ggplot(east_asia, aes(x=long, y=lat, group=group, fill=region)) + 
            geom_polygon(colour="black", size=0.1) + theme(legend.position="none")

중국, 북한, 남한, 일본

 

'R > 학습용' 카테고리의 다른 글

히트맵  (0) 2021.06.23
reshape2  (0) 2021.05.28
dpylr 패키지  (0) 2021.05.26
ggplot2  (0) 2021.05.25
데이터 전처리  (0) 2021.05.24