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
library(foreign)
library(readxl)
library(ggplot2)
library(dplyr)
library(ggiraphExtra) #지도 출력시 필요.
library(tibble)
library(maps)
library(mapproj)
library(stringr)
library(devtools)
library(kormaps2014)
library(plotly) 
 
 
 
#컬럼 이름을 영어로 변경 (호환성문제)
kp1 = rename(korpop1, pop = "총인구_명"
       name = "행정구역별_읍면동" )
 
 
#changeCode -> utf8 -> cp949
str(  changeCode(korpop1)  ) 
 
ggChoropleth( data = kp1,
              aes(fill = pop, #색상별 달리할 변수.
                         map_id = code, #지역의 기준이 되는 변수 
                         tooltip = name #지도위 표시할 지역명
                         ),
              map=kormap1,
              interactive = T)
 
str(changeCode(tbc)) #tbc : 지역별 결핵환자 수
 
ggChoropleth(data = tbc,
             aes(fill = NewPts,
                 map_id = code,
                 tooltip = name),
             map=kormap1,
             interactive = T)
 
 
= ggplot(data = mpg, aes(x = displ,
                       y = hwy,
                       col = drv)) + # 구동방식에 따라 색상 다르게.
  
  geom_point()
  
 
ggplotly(p)                   # interactive plot
 
 
diamonds
str(diamonds)
dim(diamonds)
 
= ggplot(data = diamonds, 
       aes(x = cut , fill = clarity) #투명성에 따른 빈도그래프 
       ) + geom_bar( position = "dodge")
  
ggplotly(p)
 
 
 
#시계열 그래프 (dygraphs) #time-series
 
str(economics)
head(economics)
tail(economics)
 
 
#시각화 할수 있게 y축과 시간축 데이터를 지정해서
#타입을 시계열 타입으로 변경
eco = xts(economics$unemploy, order.by = economics$date )
head(eco)
 
dygraph(eco)
 
 
#시계열 그래프의 특정 구간을 확대 축소 가능.
dygraph(eco) %>
  dyRangeSelector()
 
 
#두개의 시계열 그래프를 동시에 출력.
eco1 = xts(economics$psavert,
           order.by = economics$date)
 
eco2 = xts(economics$unemploy/2000,  #단위를 맞춰준다..!
           order.by = economics$date)
 
 
eco1
eco2
dygraph(eco)
eco1 = cbind(eco1, eco2)   #컬럼 합치기.
str(eco1)
 
eco1
 
colnames(eco1) <- c("psavert""unemploy")  #컬럼이름 변경
head(eco1)
 
dygraph(eco1) %>
  dyRangeSelector()
 
 
 
 
cs


+ Recent posts