<전국 범죄 발생>

전국, 그리고 자신이 사는 지역에서 일어나는 범죄와 그 수를 한눈에 보기 위해 준비한 자료입니다.

아래 그래프들은 전국에서 일어나는 범죄 발생 수와 광주에서 자주 일어나는 범죄유형과 범죄 발생수를 나타낸 그래프입니다.

그래프의 데이터는 공공데이터 포털 내 범죄 발생 지역별 통계 에서 가져왔습니다.

1. 전국 지역별 범죄 발생 수 현황

library(dplyr)
## Warning: 패키지 'dplyr'는 R 버전 4.3.2에서 작성되었습니다
## 
## 다음의 패키지를 부착합니다: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(readxl)
library(ggiraphExtra)
## Warning: 패키지 'ggiraphExtra'는 R 버전 4.3.2에서 작성되었습니다
library(ggplot2)
## Warning: 패키지 'ggplot2'는 R 버전 4.3.2에서 작성되었습니다
require(Kormaps)
## 필요한 패키지를 로딩중입니다: Kormaps
require(tmap)
## 필요한 패키지를 로딩중입니다: tmap
## Warning: 패키지 'tmap'는 R 버전 4.3.2에서 작성되었습니다
## Breaking News: tmap 3.x is retiring. Please test v4, e.g. with
## remotes::install_github('r-tmap/tmap')
options(repos = c(CRAN = "https://cloud.r-project.org"))
install.packages("stringi")
## 'C:/Users/ksu09/AppData/Local/R/win-library/4.3'의 위치에 패키지(들)을 설치합니다.
## (왜냐하면 'lib'가 지정되지 않았기 때문입니다)
## 패키지 'stringi'를 성공적으로 압축해제하였고 MD5 sums 이 확인되었습니다
## Warning: 패키지 'stringi'의 이전설치를 삭제할 수 없습니다
## Warning in file.copy(savedcopy, lib, recursive = TRUE):
## C:\Users\ksu09\AppData\Local\R\win-library\4.3\00LOCK\stringi\libs\x64\stringi.dll를
## C:\Users\ksu09\AppData\Local\R\win-library\4.3\stringi\libs\x64\stringi.dll로
## 복사하는데 문제가 발생했습니다: Permission denied
## Warning: 'stringi'를 복구하였습니다
## 
## 다운로드된 바이너리 패키지들은 다음의 위치에 있습니다
##  C:\Users\ksu09\AppData\Local\Temp\RtmpAxDDUw\downloaded_packages
install.packages("devtools")
## 'C:/Users/ksu09/AppData/Local/R/win-library/4.3'의 위치에 패키지(들)을 설치합니다.
## (왜냐하면 'lib'가 지정되지 않았기 때문입니다)
## 패키지 'devtools'를 성공적으로 압축해제하였고 MD5 sums 이 확인되었습니다
## 
## 다운로드된 바이너리 패키지들은 다음의 위치에 있습니다
##  C:\Users\ksu09\AppData\Local\Temp\RtmpAxDDUw\downloaded_packages
devtools::install_github("cardiomoon/kormaps2014")
## Skipping install of 'kormaps2014' from a github remote, the SHA1 (873f3c5d) has not changed since last install.
##   Use `force = TRUE` to force installation
library(kormaps2014)
## 
## 다음의 패키지를 부착합니다: 'kormaps2014'
## The following objects are masked from 'package:Kormaps':
## 
##     areacode, kormap1, kormap2, kormap3, tbc
Kcrime <- read.csv("C:\\Users\\ksu09\\Downloads\\K-crime.csv", fileEncoding = "CP949")
ggChoropleth(data = Kcrime, aes(fill = total, map_id = code, tooltip = name), map = kormap1, interactive = TRUE)

2. 광주광역시에서 발생하는 범죄 유형

GcrimeT <- read_excel("C:\\Users\\ksu09\\Downloads\\GcrimeT.xlsx")
ggplot(GcrimeT, aes(x = Category, y = Value)) + geom_bar(stat = "identity", fill = "skyblue", color = "black") + labs(title = "광주 범죄 유형", x = "범죄유형", y = "범죄 발생 수")

3. 광주광역시 지역별 범죄 발생 현황

gwangju_map <- kormap2[kormap2$code == "24020",]
gwangju_map1 <- kormap2[kormap2$code == "24030",]
gwangju_map2 <- kormap2[kormap2$code == "24010",]
gwangju_map3 <- kormap2[kormap2$code == "24040",]
gwangju_map4 <- kormap2[kormap2$code == "24050",]

Gwangju_map<- rbind(gwangju_map, gwangju_map1, gwangju_map2, gwangju_map3, gwangju_map4)
gcrime <- gcrime <- read_excel("C:\\Users\\ksu09\\Downloads\\gcrime.xlsx")
gwamap <- ggplot(Gwangju_map, aes(x = long, y = lat, group = group)) +
    geom_polygon(color = "black", fill = "white") +
    coord_fixed(ratio = 1.3) +
    labs(title = "광주 구별 지도") +
    theme_minimal()
gcrime$crime_content <- paste(gcrime$area, "살인:", gcrime$살인, "강도:", gcrime$강도, "성범죄:", gcrime$성범죄, "절도:", gcrime$절도, "폭력:", gcrime$폭력)
ggChoropleth(data = gcrime, aes(fill = total, map_id = code, tooltip = crime_content),map = gwamap$data, interactive = TRUE)