19751980198519901995200020052010−50050100
agg_ass_sumhoms_sumrape_sumrob_sumviolent_crimeChanges in the number of the violent crimes from 40 years agoyear% Difference from the beginning of period
# Set libPaths.
.libPaths("/Users/HidetakaKo/.exploratory/R/3.3")

# Load required packages.
library(lubridate)
library(tidyr)
library(urltools)
library(stringr)
library(readr)
library(broom)
library(RcppRoll)
library(tibble)
library(dplyr)
library(exploratory)

# Data Analysis Steps
read_delim("/Users/HidetakaKo/Desktop/ucr_crime_1975_2015.csv" , ",", quote = "\"", skip = 0 , col_names = TRUE , na = c("","NA"), n_max=-1 , locale=locale(encoding = "ASCII", decimal_mark = ".") , progress = FALSE) %>%
  exploratory::clean_data_frame() %>%
  gather(crime_type, crim_sum, homs_sum, rape_sum, rob_sum, agg_ass_sum, violent_crime, na.rm=TRUE) %>%
  mutate(year_since_joined = (2016 - year)) %>%
  group_by(crime_type, year) %>%
  summarize(counts=sum(crim_sum, na.rm=TRUE)) %>%
  filter(year != 2015) %>%
  mutate(total = sum(counts))