Skip to content

Instantly share code, notes, and snippets.

Created August 4, 2016 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/41e2c6f0b355ee3fc9dac5f28b2ef224 to your computer and use it in GitHub Desktop.
Save anonymous/41e2c6f0b355ee3fc9dac5f28b2ef224 to your computer and use it in GitHub Desktop.
Crimes rates in NYS
stavg <- crime_nys %>%
select(Year, Index.Rate, Property.Rate, Violent.Rate,
Firearm.Rate) %>%
group_by(Year) %>%
summarise(Index.Rate=mean(Index.Rate),
Property.Rate=mean(Property.Rate),
Violent.Rate=mean(Violent.Rate),
Firearm.Rate=mean(Firearm.Rate))
stavg_melt <- melt(stavg, id='Year', value.name = 'Value')
names(stavg_melt)[2] <- 'Crime.Type'
p3 <- ggplot(stavg_melt, aes(x=Year, y=Value)) +
geom_line(aes(color=Crime.Type),size=1) +
ggtitle('Trend of Crime Rates in New York State (minus NYC)') +
xlab('Year') +
ylab('Crime Rate (Incidents per 100,000 ppl)') +
theme_minimal()
p3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment