1) 미국의 범죄율(Murder, Assault, UrbanPop, Rape)을 한번에 작도하시오.
library(ggplot2)
library(dplyr)
library(ggiraphExtra)
library(tibble)
library(maps)
head(USArrests)
## Murder Assault UrbanPop Rape
## Alabama 13.2 236 58 21.2
## Alaska 10.0 263 48 44.5
## Arizona 8.1 294 80 31.0
## Arkansas 8.8 190 50 19.5
## California 9.0 276 91 40.6
## Colorado 7.9 204 78 38.7
str(USArrests)
## 'data.frame': 50 obs. of 4 variables:
## $ Murder : num 13.2 10 8.1 8.8 9 7.9 3.3 5.9 15.4 17.4 ...
## $ Assault : int 236 263 294 190 276 204 110 238 335 211 ...
## $ UrbanPop: int 58 48 80 50 91 78 77 72 80 60 ...
## $ Rape : num 21.2 44.5 31 19.5 40.6 38.7 11.1 15.8 31.9 25.8 ...
rownames(USArrests)
## [1] "Alabama" "Alaska" "Arizona" "Arkansas"
## [5] "California" "Colorado" "Connecticut" "Delaware"
## [9] "Florida" "Georgia" "Hawaii" "Idaho"
## [13] "Illinois" "Indiana" "Iowa" "Kansas"
## [17] "Kentucky" "Louisiana" "Maine" "Maryland"
## [21] "Massachusetts" "Michigan" "Minnesota" "Mississippi"
## [25] "Missouri" "Montana" "Nebraska" "Nevada"
## [29] "New Hampshire" "New Jersey" "New Mexico" "New York"
## [33] "North Carolina" "North Dakota" "Ohio" "Oklahoma"
## [37] "Oregon" "Pennsylvania" "Rhode Island" "South Carolina"
## [41] "South Dakota" "Tennessee" "Texas" "Utah"
## [45] "Vermont" "Virginia" "Washington" "West Virginia"
## [49] "Wisconsin" "Wyoming"
chodata <- rownames_to_column(USArrests, var = 'state')
chodata$state <- tolower(chodata$state)
chodata$sta <- substr(chodata$sta, 1, 3)
chodata <- data.frame(state = tolower(rownames(USArrests)), USArrests)
head(chodata)
## state Murder Assault UrbanPop Rape
## Alabama alabama 13.2 236 58 21.2
## Alaska alaska 10.0 263 48 44.5
## Arizona arizona 8.1 294 80 31.0
## Arkansas arkansas 8.8 190 50 19.5
## California california 9.0 276 91 40.6
## Colorado colorado 7.9 204 78 38.7
usmap <- map_data('state')
str(usmap)
## 'data.frame': 15537 obs. of 6 variables:
## $ long : num -87.5 -87.5 -87.5 -87.5 -87.6 ...
## $ lat : num 30.4 30.4 30.4 30.3 30.3 ...
## $ 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 "alabama" "alabama" "alabama" "alabama" ...
## $ subregion: chr NA NA NA NA ...
head(usmap)
## long lat group order region subregion
## 1 -87.46201 30.38968 1 1 alabama <NA>
## 2 -87.48493 30.37249 1 2 alabama <NA>
## 3 -87.52503 30.37249 1 3 alabama <NA>
## 4 -87.53076 30.33239 1 4 alabama <NA>
## 5 -87.57087 30.32665 1 5 alabama <NA>
## 6 -87.58806 30.32665 1 6 alabama <NA>
ggChoropleth(data = chodata,
aes(map_id = state),
map = usmap,
reverse = F,
interactive = T)
2) 미국 범죄율의 Rape부분을 단계 구분도로 작성하시오.
(단, 툴팁은 그림과 같이 표현하고, 클릭시 해당 state의 wikipedia 페이지를 보이도록
HTML로 저장하시오)
tooltips <- paste0(
sprintf("<p><strong>%s</strong></p>", as.character(chodata$state)),
paste0(sprintf('<p>%.0f / %.0f 만</p>', chodata$Rape, chodata$UrbanPop * 10)))
sum(chodata$Rape)
## [1] 1061.6
tooltips
## [1] "<p><strong>alabama</strong></p><p>21 / 580 만</p>"
## [2] "<p><strong>alaska</strong></p><p>44 / 480 만</p>"
## [3] "<p><strong>arizona</strong></p><p>31 / 800 만</p>"
## [4] "<p><strong>arkansas</strong></p><p>20 / 500 만</p>"
## [5] "<p><strong>california</strong></p><p>41 / 910 만</p>"
## [6] "<p><strong>colorado</strong></p><p>39 / 780 만</p>"
## [7] "<p><strong>connecticut</strong></p><p>11 / 770 만</p>"
## [8] "<p><strong>delaware</strong></p><p>16 / 720 만</p>"
## [9] "<p><strong>florida</strong></p><p>32 / 800 만</p>"
## [10] "<p><strong>georgia</strong></p><p>26 / 600 만</p>"
## [11] "<p><strong>hawaii</strong></p><p>20 / 830 만</p>"
## [12] "<p><strong>idaho</strong></p><p>14 / 540 만</p>"
## [13] "<p><strong>illinois</strong></p><p>24 / 830 만</p>"
## [14] "<p><strong>indiana</strong></p><p>21 / 650 만</p>"
## [15] "<p><strong>iowa</strong></p><p>11 / 570 만</p>"
## [16] "<p><strong>kansas</strong></p><p>18 / 660 만</p>"
## [17] "<p><strong>kentucky</strong></p><p>16 / 520 만</p>"
## [18] "<p><strong>louisiana</strong></p><p>22 / 660 만</p>"
## [19] "<p><strong>maine</strong></p><p>8 / 510 만</p>"
## [20] "<p><strong>maryland</strong></p><p>28 / 670 만</p>"
## [21] "<p><strong>massachusetts</strong></p><p>16 / 850 만</p>"
## [22] "<p><strong>michigan</strong></p><p>35 / 740 만</p>"
## [23] "<p><strong>minnesota</strong></p><p>15 / 660 만</p>"
## [24] "<p><strong>mississippi</strong></p><p>17 / 440 만</p>"
## [25] "<p><strong>missouri</strong></p><p>28 / 700 만</p>"
## [26] "<p><strong>montana</strong></p><p>16 / 530 만</p>"
## [27] "<p><strong>nebraska</strong></p><p>16 / 620 만</p>"
## [28] "<p><strong>nevada</strong></p><p>46 / 810 만</p>"
## [29] "<p><strong>new hampshire</strong></p><p>10 / 560 만</p>"
## [30] "<p><strong>new jersey</strong></p><p>19 / 890 만</p>"
## [31] "<p><strong>new mexico</strong></p><p>32 / 700 만</p>"
## [32] "<p><strong>new york</strong></p><p>26 / 860 만</p>"
## [33] "<p><strong>north carolina</strong></p><p>16 / 450 만</p>"
## [34] "<p><strong>north dakota</strong></p><p>7 / 440 만</p>"
## [35] "<p><strong>ohio</strong></p><p>21 / 750 만</p>"
## [36] "<p><strong>oklahoma</strong></p><p>20 / 680 만</p>"
## [37] "<p><strong>oregon</strong></p><p>29 / 670 만</p>"
## [38] "<p><strong>pennsylvania</strong></p><p>15 / 720 만</p>"
## [39] "<p><strong>rhode island</strong></p><p>8 / 870 만</p>"
## [40] "<p><strong>south carolina</strong></p><p>22 / 480 만</p>"
## [41] "<p><strong>south dakota</strong></p><p>13 / 450 만</p>"
## [42] "<p><strong>tennessee</strong></p><p>27 / 590 만</p>"
## [43] "<p><strong>texas</strong></p><p>26 / 800 만</p>"
## [44] "<p><strong>utah</strong></p><p>23 / 800 만</p>"
## [45] "<p><strong>vermont</strong></p><p>11 / 320 만</p>"
## [46] "<p><strong>virginia</strong></p><p>21 / 630 만</p>"
## [47] "<p><strong>washington</strong></p><p>26 / 730 만</p>"
## [48] "<p><strong>west virginia</strong></p><p>9 / 390 만</p>"
## [49] "<p><strong>wisconsin</strong></p><p>11 / 660 만</p>"
## [50] "<p><strong>wyoming</strong></p><p>16 / 600 만</p>"
str(chodata)
## 'data.frame': 50 obs. of 5 variables:
## $ state : Factor w/ 50 levels "alabama","alaska",..: 1 2 3 4 5 6 7 8 9 10 ...
## $ Murder : num 13.2 10 8.1 8.8 9 7.9 3.3 5.9 15.4 17.4 ...
## $ Assault : int 236 263 294 190 276 204 110 238 335 211 ...
## $ UrbanPop: int 58 48 80 50 91 78 77 72 80 60 ...
## $ Rape : num 21.2 44.5 31 19.5 40.6 38.7 11.1 15.8 31.9 25.8 ...
library(stringi)
# tooltips <- stringi::stri_enc_toutf8(tooltips)
tooltips <- stringi::stri_escape_unicode(tooltips)
onclick <- sprintf('window.open("http://en.wikipedia.org/wiki/%s")', as.character(chodata$state))
onclick
## [1] "window.open(\"http://en.wikipedia.org/wiki/alabama\")"
## [2] "window.open(\"http://en.wikipedia.org/wiki/alaska\")"
## [3] "window.open(\"http://en.wikipedia.org/wiki/arizona\")"
## [4] "window.open(\"http://en.wikipedia.org/wiki/arkansas\")"
## [5] "window.open(\"http://en.wikipedia.org/wiki/california\")"
## [6] "window.open(\"http://en.wikipedia.org/wiki/colorado\")"
## [7] "window.open(\"http://en.wikipedia.org/wiki/connecticut\")"
## [8] "window.open(\"http://en.wikipedia.org/wiki/delaware\")"
## [9] "window.open(\"http://en.wikipedia.org/wiki/florida\")"
## [10] "window.open(\"http://en.wikipedia.org/wiki/georgia\")"
## [11] "window.open(\"http://en.wikipedia.org/wiki/hawaii\")"
## [12] "window.open(\"http://en.wikipedia.org/wiki/idaho\")"
## [13] "window.open(\"http://en.wikipedia.org/wiki/illinois\")"
## [14] "window.open(\"http://en.wikipedia.org/wiki/indiana\")"
## [15] "window.open(\"http://en.wikipedia.org/wiki/iowa\")"
## [16] "window.open(\"http://en.wikipedia.org/wiki/kansas\")"
## [17] "window.open(\"http://en.wikipedia.org/wiki/kentucky\")"
## [18] "window.open(\"http://en.wikipedia.org/wiki/louisiana\")"
## [19] "window.open(\"http://en.wikipedia.org/wiki/maine\")"
## [20] "window.open(\"http://en.wikipedia.org/wiki/maryland\")"
## [21] "window.open(\"http://en.wikipedia.org/wiki/massachusetts\")"
## [22] "window.open(\"http://en.wikipedia.org/wiki/michigan\")"
## [23] "window.open(\"http://en.wikipedia.org/wiki/minnesota\")"
## [24] "window.open(\"http://en.wikipedia.org/wiki/mississippi\")"
## [25] "window.open(\"http://en.wikipedia.org/wiki/missouri\")"
## [26] "window.open(\"http://en.wikipedia.org/wiki/montana\")"
## [27] "window.open(\"http://en.wikipedia.org/wiki/nebraska\")"
## [28] "window.open(\"http://en.wikipedia.org/wiki/nevada\")"
## [29] "window.open(\"http://en.wikipedia.org/wiki/new hampshire\")"
## [30] "window.open(\"http://en.wikipedia.org/wiki/new jersey\")"
## [31] "window.open(\"http://en.wikipedia.org/wiki/new mexico\")"
## [32] "window.open(\"http://en.wikipedia.org/wiki/new york\")"
## [33] "window.open(\"http://en.wikipedia.org/wiki/north carolina\")"
## [34] "window.open(\"http://en.wikipedia.org/wiki/north dakota\")"
## [35] "window.open(\"http://en.wikipedia.org/wiki/ohio\")"
## [36] "window.open(\"http://en.wikipedia.org/wiki/oklahoma\")"
## [37] "window.open(\"http://en.wikipedia.org/wiki/oregon\")"
## [38] "window.open(\"http://en.wikipedia.org/wiki/pennsylvania\")"
## [39] "window.open(\"http://en.wikipedia.org/wiki/rhode island\")"
## [40] "window.open(\"http://en.wikipedia.org/wiki/south carolina\")"
## [41] "window.open(\"http://en.wikipedia.org/wiki/south dakota\")"
## [42] "window.open(\"http://en.wikipedia.org/wiki/tennessee\")"
## [43] "window.open(\"http://en.wikipedia.org/wiki/texas\")"
## [44] "window.open(\"http://en.wikipedia.org/wiki/utah\")"
## [45] "window.open(\"http://en.wikipedia.org/wiki/vermont\")"
## [46] "window.open(\"http://en.wikipedia.org/wiki/virginia\")"
## [47] "window.open(\"http://en.wikipedia.org/wiki/washington\")"
## [48] "window.open(\"http://en.wikipedia.org/wiki/west virginia\")"
## [49] "window.open(\"http://en.wikipedia.org/wiki/wisconsin\")"
## [50] "window.open(\"http://en.wikipedia.org/wiki/wyoming\")"
library(ggiraph)
rc <- ggplot(chodata, aes(data = Murder, map_id = state)) +
geom_map_interactive(
aes(fill = Rape,
data_id = state,
tooltip = tooltips,
onclick = onclick),
map = usmap) +
expand_limits(x = usmap$long, y = usmap$lat) +
scale_fill_gradient2('Rape', low = 'red', high = "blue", mid = "green") +
labs(title = "USA Rape")
rc

ggiraph(code = print(rc))
girafe(ggobj = rc)
3) 시도별(kormap1) 결핵환자수(kormaps2014::tbc)를 단계 구분도로 작성하시오.(우리나라)
(단, 환자수는 2006년부터 2015년 총합, NA인 지역은 0으로 표시할 것.)
library(dplyr)
library(ggiraphExtra)
library(ggplot2)
library(kormaps2014)
tbc <- kormaps2014::tbc
tbc$NewPts <- ifelse(is.na(tbc$NewPts), 0, tbc$NewPts)
tbc
## name1 code name year NewPts
## 1 媛뺤썝 32 媛뺤썝\xeb룄 2001 1396
## 2 寃쎄린 31 寃쎄린\xeb룄 2001 4843
## 3 寃쎈궓 38 寃쎌긽\xeb궓\xeb룄 2001 1749
## 4 寃쎈턿 37 寃쎌긽遺곷룄 2001 2075
## 5 愿묒< 24 愿묒<愿묒뿭\xec떆 2001 658
## 6 \xeb\x8c\u0080援\xac 22 \xeb\x8c\u0080援ш킅\xec뿭\xec떆 2001 1406
## 7 \xeb\x8c\u0080\xec쟾 25 \xeb\x8c\u0080\xec쟾愿묒뿭\xec떆 2001 1345
## 8 遺\u0080\xec궛 21 遺\u0080\xec궛愿묒뿭\xec떆 2001 3188
## 9 \xec꽌\xec슱 11 \xec꽌\xec슱\xed듅蹂꾩떆 2001 11178
## 10 \xec꽭醫\x85 29 \xec꽭醫낇듅蹂꾩옄移섏떆 2001 0
## 11 \xec슱\xec궛 26 \xec슱\xec궛愿묒뿭\xec떆 2001 422
## 12 \xec씤泥\x9c 23 \xec씤泥쒓킅\xec뿭\xec떆 2001 834
## 13 \xec쟾\xeb궓 36 \xec쟾\xeb씪\xeb궓\xeb룄 2001 1173
## 14 \xec쟾遺\x81 35 \xec쟾\xeb씪遺곷룄 2001 1798
## 15 \xec젣二\xbc 39 \xec젣二쇳듅蹂꾩옄移섎룄 2001 321
## 16 異⑸궓 34 異⑹껌\xeb궓\xeb룄 2001 777
## 17 異⑸턿 33 異⑹껌遺곷룄 2001 960
## 18 媛뺤썝 32 媛뺤썝\xeb룄 2002 1294
## 19 寃쎄린 31 寃쎄린\xeb룄 2002 4197
## 20 寃쎈궓 38 寃쎌긽\xeb궓\xeb룄 2002 1745
## 21 寃쎈턿 37 寃쎌긽遺곷룄 2002 1518
## 22 愿묒< 24 愿묒<愿묒뿭\xec떆 2002 709
## 23 \xeb\x8c\u0080援\xac 22 \xeb\x8c\u0080援ш킅\xec뿭\xec떆 2002 1327
## 24 \xeb\x8c\u0080\xec쟾 25 \xeb\x8c\u0080\xec쟾愿묒뿭\xec떆 2002 572
## 25 遺\u0080\xec궛 21 遺\u0080\xec궛愿묒뿭\xec떆 2002 2759
## 26 \xec꽌\xec슱 11 \xec꽌\xec슱\xed듅蹂꾩떆 2002 10468
## 27 \xec꽭醫\x85 29 \xec꽭醫낇듅蹂꾩옄移섏떆 2002 0
## 28 \xec슱\xec궛 26 \xec슱\xec궛愿묒뿭\xec떆 2002 382
## 29 \xec씤泥\x9c 23 \xec씤泥쒓킅\xec뿭\xec떆 2002 1253
## 30 \xec쟾\xeb궓 36 \xec쟾\xeb씪\xeb궓\xeb룄 2002 1690
## 31 \xec쟾遺\x81 35 \xec쟾\xeb씪遺곷룄 2002 2116
## 32 \xec젣二\xbc 39 \xec젣二쇳듅蹂꾩옄移섎룄 2002 291
## 33 異⑸궓 34 異⑹껌\xeb궓\xeb룄 2002 895
## 34 異⑸턿 33 異⑹껌遺곷룄 2002 794
## 35 媛뺤썝 32 媛뺤썝\xeb룄 2003 1100
## 36 寃쎄린 31 寃쎄린\xeb룄 2003 4803
## 37 寃쎈궓 38 寃쎌긽\xeb궓\xeb룄 2003 1916
## 38 寃쎈턿 37 寃쎌긽遺곷룄 2003 1536
## 39 愿묒< 24 愿묒<愿묒뿭\xec떆 2003 816
## 40 \xeb\x8c\u0080援\xac 22 \xeb\x8c\u0080援ш킅\xec뿭\xec떆 2003 1438
## 41 \xeb\x8c\u0080\xec쟾 25 \xeb\x8c\u0080\xec쟾愿묒뿭\xec떆 2003 597
## 42 遺\u0080\xec궛 21 遺\u0080\xec궛愿묒뿭\xec떆 2003 2643
## 43 \xec꽌\xec슱 11 \xec꽌\xec슱\xed듅蹂꾩떆 2003 9277
## 44 \xec꽭醫\x85 29 \xec꽭醫낇듅蹂꾩옄移섏떆 2003 0
## 45 \xec슱\xec궛 26 \xec슱\xec궛愿묒뿭\xec떆 2003 421
## 46 \xec씤泥\x9c 23 \xec씤泥쒓킅\xec뿭\xec떆 2003 1497
## 47 \xec쟾\xeb궓 36 \xec쟾\xeb씪\xeb궓\xeb룄 2003 1241
## 48 \xec쟾遺\x81 35 \xec쟾\xeb씪遺곷룄 2003 1368
## 49 \xec젣二\xbc 39 \xec젣二쇳듅蹂꾩옄移섎룄 2003 355
## 50 異⑸궓 34 異⑹껌\xeb궓\xeb룄 2003 901
## 51 異⑸턿 33 異⑹껌遺곷룄 2003 778
## 52 媛뺤썝 32 媛뺤썝\xeb룄 2004 1164
## 53 寃쎄린 31 寃쎄린\xeb룄 2004 5225
## 54 寃쎈궓 38 寃쎌긽\xeb궓\xeb룄 2004 2033
## 55 寃쎈턿 37 寃쎌긽遺곷룄 2004 1474
## 56 愿묒< 24 愿묒<愿묒뿭\xec떆 2004 766
## 57 \xeb\x8c\u0080援\xac 22 \xeb\x8c\u0080援ш킅\xec뿭\xec떆 2004 1331
## 58 \xeb\x8c\u0080\xec쟾 25 \xeb\x8c\u0080\xec쟾愿묒뿭\xec떆 2004 851
## 59 遺\u0080\xec궛 21 遺\u0080\xec궛愿묒뿭\xec떆 2004 2822
## 60 \xec꽌\xec슱 11 \xec꽌\xec슱\xed듅蹂꾩떆 2004 9310
## 61 \xec꽭醫\x85 29 \xec꽭醫낇듅蹂꾩옄移섏떆 2004 0
## 62 \xec슱\xec궛 26 \xec슱\xec궛愿묒뿭\xec떆 2004 409
## 63 \xec씤泥\x9c 23 \xec씤泥쒓킅\xec뿭\xec떆 2004 1499
## 64 \xec쟾\xeb궓 36 \xec쟾\xeb씪\xeb궓\xeb룄 2004 1260
## 65 \xec쟾遺\x81 35 \xec쟾\xeb씪遺곷룄 2004 1393
## 66 \xec젣二\xbc 39 \xec젣二쇳듅蹂꾩옄移섎룄 2004 295
## 67 異⑸궓 34 異⑹껌\xeb궓\xeb룄 2004 949
## 68 異⑸턿 33 異⑹껌遺곷룄 2004 722
## 69 媛뺤썝 32 媛뺤썝\xeb룄 2005 1635
## 70 寃쎄린 31 寃쎄린\xeb룄 2005 5478
## 71 寃쎈궓 38 寃쎌긽\xeb궓\xeb룄 2005 2325
## 72 寃쎈턿 37 寃쎌긽遺곷룄 2005 1627
## 73 愿묒< 24 愿묒<愿묒뿭\xec떆 2005 1075
## 74 \xeb\x8c\u0080援\xac 22 \xeb\x8c\u0080援ш킅\xec뿭\xec떆 2005 1577
## 75 \xeb\x8c\u0080\xec쟾 25 \xeb\x8c\u0080\xec쟾愿묒뿭\xec떆 2005 815
## 76 遺\u0080\xec궛 21 遺\u0080\xec궛愿묒뿭\xec떆 2005 3403
## 77 \xec꽌\xec슱 11 \xec꽌\xec슱\xed듅蹂꾩떆 2005 9787
## 78 \xec꽭醫\x85 29 \xec꽭醫낇듅蹂꾩옄移섏떆 2005 0
## 79 \xec슱\xec궛 26 \xec슱\xec궛愿묒뿭\xec떆 2005 535
## 80 \xec씤泥\x9c 23 \xec씤泥쒓킅\xec뿭\xec떆 2005 1454
## 81 \xec쟾\xeb궓 36 \xec쟾\xeb씪\xeb궓\xeb룄 2005 1341
## 82 \xec쟾遺\x81 35 \xec쟾\xeb씪遺곷룄 2005 1645
## 83 \xec젣二\xbc 39 \xec젣二쇳듅蹂꾩옄移섎룄 2005 302
## 84 異⑸궓 34 異⑹껌\xeb궓\xeb룄 2005 1335
## 85 異⑸턿 33 異⑹껌遺곷룄 2005 935
## 86 媛뺤썝 32 媛뺤썝\xeb룄 2006 1718
## 87 寃쎄린 31 寃쎄린\xeb룄 2006 5396
## 88 寃쎈궓 38 寃쎌긽\xeb궓\xeb룄 2006 2681
## 89 寃쎈턿 37 寃쎌긽遺곷룄 2006 1758
## 90 愿묒< 24 愿묒<愿묒뿭\xec떆 2006 866
## 91 \xeb\x8c\u0080援\xac 22 \xeb\x8c\u0080援ш킅\xec뿭\xec떆 2006 1440
## 92 \xeb\x8c\u0080\xec쟾 25 \xeb\x8c\u0080\xec쟾愿묒뿭\xec떆 2006 834
## 93 遺\u0080\xec궛 21 遺\u0080\xec궛愿묒뿭\xec떆 2006 3762
## 94 \xec꽌\xec슱 11 \xec꽌\xec슱\xed듅蹂꾩떆 2006 9458
## 95 \xec꽭醫\x85 29 \xec꽭醫낇듅蹂꾩옄移섏떆 2006 0
## 96 \xec슱\xec궛 26 \xec슱\xec궛愿묒뿭\xec떆 2006 583
## 97 \xec씤泥\x9c 23 \xec씤泥쒓킅\xec뿭\xec떆 2006 1386
## 98 \xec쟾\xeb궓 36 \xec쟾\xeb씪\xeb궓\xeb룄 2006 1338
## 99 \xec쟾遺\x81 35 \xec쟾\xeb씪遺곷룄 2006 1530
## 100 \xec젣二\xbc 39 \xec젣二쇳듅蹂꾩옄移섎룄 2006 314
## 101 異⑸궓 34 異⑹껌\xeb궓\xeb룄 2006 1421
## 102 異⑸턿 33 異⑹껌遺곷룄 2006 876
## 103 媛뺤썝 32 媛뺤썝\xeb룄 2007 1489
## 104 寃쎄린 31 寃쎄린\xeb룄 2007 5413
## 105 寃쎈궓 38 寃쎌긽\xeb궓\xeb룄 2007 2274
## 106 寃쎈턿 37 寃쎌긽遺곷룄 2007 1533
## 107 愿묒< 24 愿묒<愿묒뿭\xec떆 2007 917
## 108 \xeb\x8c\u0080援\xac 22 \xeb\x8c\u0080援ш킅\xec뿭\xec떆 2007 1853
## 109 \xeb\x8c\u0080\xec쟾 25 \xeb\x8c\u0080\xec쟾愿묒뿭\xec떆 2007 724
## 110 遺\u0080\xec궛 21 遺\u0080\xec궛愿묒뿭\xec떆 2007 3839
## 111 \xec꽌\xec슱 11 \xec꽌\xec슱\xed듅蹂꾩떆 2007 9588
## 112 \xec꽭醫\x85 29 \xec꽭醫낇듅蹂꾩옄移섏떆 2007 0
## 113 \xec슱\xec궛 26 \xec슱\xec궛愿묒뿭\xec떆 2007 806
## 114 \xec씤泥\x9c 23 \xec씤泥쒓킅\xec뿭\xec떆 2007 1399
## 115 \xec쟾\xeb궓 36 \xec쟾\xeb씪\xeb궓\xeb룄 2007 1189
## 116 \xec쟾遺\x81 35 \xec쟾\xeb씪遺곷룄 2007 1375
## 117 \xec젣二\xbc 39 \xec젣二쇳듅蹂꾩옄移섎룄 2007 229
## 118 異⑸궓 34 異⑹껌\xeb궓\xeb룄 2007 1318
## 119 異⑸턿 33 異⑹껌遺곷룄 2007 764
## 120 媛뺤썝 32 媛뺤썝\xeb룄 2008 1450
## 121 寃쎄린 31 寃쎄린\xeb룄 2008 5188
## 122 寃쎈궓 38 寃쎌긽\xeb궓\xeb룄 2008 2267
## 123 寃쎈턿 37 寃쎌긽遺곷룄 2008 1530
## 124 愿묒< 24 愿묒<愿묒뿭\xec떆 2008 934
## 125 \xeb\x8c\u0080援\xac 22 \xeb\x8c\u0080援ш킅\xec뿭\xec떆 2008 2043
## 126 \xeb\x8c\u0080\xec쟾 25 \xeb\x8c\u0080\xec쟾愿묒뿭\xec떆 2008 1184
## 127 遺\u0080\xec궛 21 遺\u0080\xec궛愿묒뿭\xec떆 2008 3461
## 128 \xec꽌\xec슱 11 \xec꽌\xec슱\xed듅蹂꾩떆 2008 8952
## 129 \xec꽭醫\x85 29 \xec꽭醫낇듅蹂꾩옄移섏떆 2008 0
## 130 \xec슱\xec궛 26 \xec슱\xec궛愿묒뿭\xec떆 2008 831
## 131 \xec씤泥\x9c 23 \xec씤泥쒓킅\xec뿭\xec떆 2008 1374
## 132 \xec쟾\xeb궓 36 \xec쟾\xeb씪\xeb궓\xeb룄 2008 1124
## 133 \xec쟾遺\x81 35 \xec쟾\xeb씪遺곷룄 2008 1337
## 134 \xec젣二\xbc 39 \xec젣二쇳듅蹂꾩옄移섎룄 2008 401
## 135 異⑸궓 34 異⑹껌\xeb궓\xeb룄 2008 1290
## 136 異⑸턿 33 異⑹껌遺곷룄 2008 791
## 137 媛뺤썝 32 媛뺤썝\xeb룄 2009 1513
## 138 寃쎄린 31 寃쎄린\xeb룄 2009 5143
## 139 寃쎈궓 38 寃쎌긽\xeb궓\xeb룄 2009 2114
## 140 寃쎈턿 37 寃쎌긽遺곷룄 2009 1593
## 141 愿묒< 24 愿묒<愿묒뿭\xec떆 2009 1182
## 142 \xeb\x8c\u0080援\xac 22 \xeb\x8c\u0080援ш킅\xec뿭\xec떆 2009 2608
## 143 \xeb\x8c\u0080\xec쟾 25 \xeb\x8c\u0080\xec쟾愿묒뿭\xec떆 2009 1384
## 144 遺\u0080\xec궛 21 遺\u0080\xec궛愿묒뿭\xec떆 2009 3307
## 145 \xec꽌\xec슱 11 \xec꽌\xec슱\xed듅蹂꾩떆 2009 9453
## 146 \xec꽭醫\x85 29 \xec꽭醫낇듅蹂꾩옄移섏떆 2009 0
## 147 \xec슱\xec궛 26 \xec슱\xec궛愿묒뿭\xec떆 2009 763
## 148 \xec씤泥\x9c 23 \xec씤泥쒓킅\xec뿭\xec떆 2009 1588
## 149 \xec쟾\xeb궓 36 \xec쟾\xeb씪\xeb궓\xeb룄 2009 1243
## 150 \xec쟾遺\x81 35 \xec쟾\xeb씪遺곷룄 2009 1566
## 151 \xec젣二\xbc 39 \xec젣二쇳듅蹂꾩옄移섎룄 2009 396
## 152 異⑸궓 34 異⑹껌\xeb궓\xeb룄 2009 1200
## 153 異⑸턿 33 異⑹껌遺곷룄 2009 792
## 154 媛뺤썝 32 媛뺤썝\xeb룄 2010 1449
## 155 寃쎄린 31 寃쎄린\xeb룄 2010 5263
## 156 寃쎈궓 38 寃쎌긽\xeb궓\xeb룄 2010 2305
## 157 寃쎈턿 37 寃쎌긽遺곷룄 2010 1600
## 158 愿묒< 24 愿묒<愿묒뿭\xec떆 2010 1124
## 159 \xeb\x8c\u0080援\xac 22 \xeb\x8c\u0080援ш킅\xec뿭\xec떆 2010 2703
## 160 \xeb\x8c\u0080\xec쟾 25 \xeb\x8c\u0080\xec쟾愿묒뿭\xec떆 2010 1322
## 161 遺\u0080\xec궛 21 遺\u0080\xec궛愿묒뿭\xec떆 2010 3533
## 162 \xec꽌\xec슱 11 \xec꽌\xec슱\xed듅蹂꾩떆 2010 9675
## 163 \xec꽭醫\x85 29 \xec꽭醫낇듅蹂꾩옄移섏떆 2010 0
## 164 \xec슱\xec궛 26 \xec슱\xec궛愿묒뿭\xec떆 2010 870
## 165 \xec씤泥\x9c 23 \xec씤泥쒓킅\xec뿭\xec떆 2010 1705
## 166 \xec쟾\xeb궓 36 \xec쟾\xeb씪\xeb궓\xeb룄 2010 1092
## 167 \xec쟾遺\x81 35 \xec쟾\xeb씪遺곷룄 2010 1361
## 168 \xec젣二\xbc 39 \xec젣二쇳듅蹂꾩옄移섎룄 2010 430
## 169 異⑸궓 34 異⑹껌\xeb궓\xeb룄 2010 1111
## 170 異⑸턿 33 異⑹껌遺곷룄 2010 762
## 171 媛뺤썝 32 媛뺤썝\xeb룄 2011 1366
## 172 寃쎄린 31 寃쎄린\xeb룄 2011 6776
## 173 寃쎈궓 38 寃쎌긽\xeb궓\xeb룄 2011 2217
## 174 寃쎈턿 37 寃쎌긽遺곷룄 2011 2004
## 175 愿묒< 24 愿묒<愿묒뿭\xec떆 2011 1247
## 176 \xeb\x8c\u0080援\xac 22 \xeb\x8c\u0080援ш킅\xec뿭\xec떆 2011 2898
## 177 \xeb\x8c\u0080\xec쟾 25 \xeb\x8c\u0080\xec쟾愿묒뿭\xec떆 2011 1251
## 178 遺\u0080\xec궛 21 遺\u0080\xec궛愿묒뿭\xec떆 2011 3630
## 179 \xec꽌\xec슱 11 \xec꽌\xec슱\xed듅蹂꾩떆 2011 10396
## 180 \xec꽭醫\x85 29 \xec꽭醫낇듅蹂꾩옄移섏떆 2011 0
## 181 \xec슱\xec궛 26 \xec슱\xec궛愿묒뿭\xec떆 2011 965
## 182 \xec씤泥\x9c 23 \xec씤泥쒓킅\xec뿭\xec떆 2011 1845
## 183 \xec쟾\xeb궓 36 \xec쟾\xeb씪\xeb궓\xeb룄 2011 1216
## 184 \xec쟾遺\x81 35 \xec쟾\xeb씪遺곷룄 2011 1385
## 185 \xec젣二\xbc 39 \xec젣二쇳듅蹂꾩옄移섎룄 2011 450
## 186 異⑸궓 34 異⑹껌\xeb궓\xeb룄 2011 1010
## 187 異⑸턿 33 異⑹껌遺곷룄 2011 901
## 188 媛뺤썝 32 媛뺤썝\xeb룄 2012 1413
## 189 寃쎄린 31 寃쎄린\xeb룄 2012 7818
## 190 寃쎈궓 38 寃쎌긽\xeb궓\xeb룄 2012 2585
## 191 寃쎈턿 37 寃쎌긽遺곷룄 2012 2789
## 192 愿묒< 24 愿묒<愿묒뿭\xec떆 2012 1072
## 193 \xeb\x8c\u0080援\xac 22 \xeb\x8c\u0080援ш킅\xec뿭\xec떆 2012 2150
## 194 \xeb\x8c\u0080\xec쟾 25 \xeb\x8c\u0080\xec쟾愿묒뿭\xec떆 2012 884
## 195 遺\u0080\xec궛 21 遺\u0080\xec궛愿묒뿭\xec떆 2012 3278
## 196 \xec꽌\xec슱 11 \xec꽌\xec슱\xed듅蹂꾩떆 2012 8261
## 197 \xec꽭醫\x85 29 \xec꽭醫낇듅蹂꾩옄移섏떆 2012 72
## 198 \xec슱\xec궛 26 \xec슱\xec궛愿묒뿭\xec떆 2012 792
## 199 \xec씤泥\x9c 23 \xec씤泥쒓킅\xec뿭\xec떆 2012 1983
## 200 \xec쟾\xeb궓 36 \xec쟾\xeb씪\xeb궓\xeb룄 2012 1942
## 201 \xec쟾遺\x81 35 \xec쟾\xeb씪遺곷룄 2012 1345
## 202 \xec젣二\xbc 39 \xec젣二쇳듅蹂꾩옄移섎룄 2012 498
## 203 異⑸궓 34 異⑹껌\xeb궓\xeb룄 2012 1476
## 204 異⑸턿 33 異⑹껌遺곷룄 2012 1187
## 205 媛뺤썝 32 媛뺤썝\xeb룄 2013 1369
## 206 寃쎄린 31 寃쎄린\xeb룄 2013 7523
## 207 寃쎈궓 38 寃쎌긽\xeb궓\xeb룄 2013 2406
## 208 寃쎈턿 37 寃쎌긽遺곷룄 2013 2540
## 209 愿묒< 24 愿묒<愿묒뿭\xec떆 2013 886
## 210 \xeb\x8c\u0080援\xac 22 \xeb\x8c\u0080援ш킅\xec뿭\xec떆 2013 1878
## 211 \xeb\x8c\u0080\xec쟾 25 \xeb\x8c\u0080\xec쟾愿묒뿭\xec떆 2013 830
## 212 遺\u0080\xec궛 21 遺\u0080\xec궛愿묒뿭\xec떆 2013 2771
## 213 \xec꽌\xec슱 11 \xec꽌\xec슱\xed듅蹂꾩떆 2013 7389
## 214 \xec꽭醫\x85 29 \xec꽭醫낇듅蹂꾩옄移섏떆 2013 72
## 215 \xec슱\xec궛 26 \xec슱\xec궛愿묒뿭\xec떆 2013 821
## 216 \xec씤泥\x9c 23 \xec씤泥쒓킅\xec뿭\xec떆 2013 1904
## 217 \xec쟾\xeb궓 36 \xec쟾\xeb씪\xeb궓\xeb룄 2013 1676
## 218 \xec쟾遺\x81 35 \xec쟾\xeb씪遺곷룄 2013 1225
## 219 \xec젣二\xbc 39 \xec젣二쇳듅蹂꾩옄移섎룄 2013 409
## 220 異⑸궓 34 異⑹껌\xeb궓\xeb룄 2013 1372
## 221 異⑸턿 33 異⑹껌遺곷룄 2013 1018
## 222 媛뺤썝 32 媛뺤썝\xeb룄 2014 1555
## 223 寃쎄린 31 寃쎄린\xeb룄 2014 7177
## 224 寃쎈궓 38 寃쎌긽\xeb궓\xeb룄 2014 2295
## 225 寃쎈턿 37 寃쎌긽遺곷룄 2014 2472
## 226 愿묒< 24 愿묒<愿묒뿭\xec떆 2014 817
## 227 \xeb\x8c\u0080援\xac 22 \xeb\x8c\u0080援ш킅\xec뿭\xec떆 2014 1881
## 228 \xeb\x8c\u0080\xec쟾 25 \xeb\x8c\u0080\xec쟾愿묒뿭\xec떆 2014 859
## 229 遺\u0080\xec궛 21 遺\u0080\xec궛愿묒뿭\xec떆 2014 2548
## 230 \xec꽌\xec슱 11 \xec꽌\xec슱\xed듅蹂꾩떆 2014 6831
## 231 \xec꽭醫\x85 29 \xec꽭醫낇듅蹂꾩옄移섏떆 2014 71
## 232 \xec슱\xec궛 26 \xec슱\xec궛愿묒뿭\xec떆 2014 738
## 233 \xec씤泥\x9c 23 \xec씤泥쒓킅\xec뿭\xec떆 2014 1766
## 234 \xec쟾\xeb궓 36 \xec쟾\xeb씪\xeb궓\xeb룄 2014 1676
## 235 \xec쟾遺\x81 35 \xec쟾\xeb씪遺곷룄 2014 1304
## 236 \xec젣二\xbc 39 \xec젣二쇳듅蹂꾩옄移섎룄 2014 375
## 237 異⑸궓 34 異⑹껌\xeb궓\xeb룄 2014 1506
## 238 異⑸턿 33 異⑹껌遺곷룄 2014 998
## 239 媛뺤썝 32 媛뺤썝\xeb룄 2015 1368
## 240 寃쎄린 31 寃쎄린\xeb룄 2015 6782
## 241 寃쎈궓 38 寃쎌긽\xeb궓\xeb룄 2015 2217
## 242 寃쎈턿 37 寃쎌긽遺곷룄 2015 2328
## 243 愿묒< 24 愿묒<愿묒뿭\xec떆 2015 803
## 244 \xeb\x8c\u0080援\xac 22 \xeb\x8c\u0080援ш킅\xec뿭\xec떆 2015 1518
## 245 \xeb\x8c\u0080\xec쟾 25 \xeb\x8c\u0080\xec쟾愿묒뿭\xec떆 2015 730
## 246 遺\u0080\xec궛 21 遺\u0080\xec궛愿묒뿭\xec떆 2015 2386
## 247 \xec꽌\xec슱 11 \xec꽌\xec슱\xed듅蹂꾩떆 2015 6011
## 248 \xec꽭醫\x85 29 \xec꽭醫낇듅蹂꾩옄移섏떆 2015 80
## 249 \xec슱\xec궛 26 \xec슱\xec궛愿묒뿭\xec떆 2015 634
## 250 \xec씤泥\x9c 23 \xec씤泥쒓킅\xec뿭\xec떆 2015 1646
## 251 \xec쟾\xeb궓 36 \xec쟾\xeb씪\xeb궓\xeb룄 2015 1657
## 252 \xec쟾遺\x81 35 \xec쟾\xeb씪遺곷룄 2015 1206
## 253 \xec젣二\xbc 39 \xec젣二쇳듅蹂꾩옄移섎룄 2015 374
## 254 異⑸궓 34 異⑹껌\xeb궓\xeb룄 2015 1455
## 255 異⑸턿 33 異⑹껌遺곷룄 2015 986
tbc <- tbc %>%
filter(year %in% 2006:2015) %>%
group_by(name1, code) %>%
summarise(s = sum(NewPts))
tbc
## # A tibble: 17 x 3
## # Groups: name1 [17]
## name1 code s
## <fct> <int> <dbl>
## 1 媛뺤썝 32 14690
## 2 寃쎄린 31 62479
## 3 寃쎈궓 38 23361
## 4 寃쎈턿 37 20147
## 5 愿묒< 24 9848
## 6 "?\u0080援?" 22 20972
## 7 "?\u0080??" 25 10002
## 8 "遺\u0080??" 21 32515
## 9 ?쒖슱 11 86014
## 10 ?몄쥌 29 295
## 11 ?몄궛 26 7803
## 12 ?몄쿇 23 16596
## 13 ?꾨궓 36 14153
## 14 ?꾨턿 35 13634
## 15 ?쒖< 39 3876
## 16 異⑸궓 34 13159
## 17 異⑸턿 33 9075
tooltips2 <- sprintf("<p>결핵 환자 수 : %.0f명</p>", tbc$s)
tooltips2 <- stringi::stri_enc_toutf8(tooltips2)
result <- ggplot(tbc, aes(data = s, map_id = code)) +
geom_map_interactive(
aes(fill = s, tooltip = tooltips2),
map = kormap1) +
expand_limits(x = kormap1$long, y = kormap1$lat) +
scale_fill_gradient2('결핵 환자 수', low = 'red', high = "blue", mid = "green") +
labs(title = "시도별 결핵 환자 수")
ggiraph(code = print(result))
girafe(ggobj = result)