Created
August 4, 2016 22:00
-
-
Save anonymous/6630133e77960f7b1a0b58fde777cd4f to your computer and use it in GitHub Desktop.
Crime rates in NYC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ctysum <- crime_nyc %>% | |
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)) | |
ctysum_melt <- melt(ctysum, id='Year', value.name = 'Value') | |
names(ctysum_melt)[2] <- 'Crime.Type' | |
p3 <- ggplot(ctysum_melt, aes(x=Year, y=Value)) + | |
geom_line(aes(color=Crime.Type),size=1) + | |
ggtitle('Trend of Crime Rates in New York City') + | |
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