Skip to content

Instantly share code, notes, and snippets.

@yeere91
Created October 24, 2016 04:44
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 yeere91/9845743d6701b7c44d790715d1bbf845 to your computer and use it in GitHub Desktop.
Save yeere91/9845743d6701b7c44d790715d1bbf845 to your computer and use it in GitHub Desktop.
# Summarizing the data by year
crashes_in_2015 = zip_counts %>% filter(year==2015)
crashes_in_2014 = zip_counts %>% filter(year==2014)
crashes_in_2013 = zip_counts %>% filter(year==2013)
## Get the diffs for 2014 vs 2015
y2015.vs.y2014 = left_join(crashes_in_2015,crashes_in_2014,by = 'region')
df20152014 = as.data.frame(y2015.vs.y2014) %>% select(year.x,region,value.x,value.y)
df20152014 = df20152014 %>% mutate(value=value.x-value.y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment