Skip to content

Instantly share code, notes, and snippets.

@jonathanlxy
Last active July 25, 2016 14:20
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 jonathanlxy/d19d840b79282efa0b3d7f097a427751 to your computer and use it in GitHub Desktop.
Save jonathanlxy/d19d840b79282efa0b3d7f097a427751 to your computer and use it in GitHub Desktop.
Vision Zero Visualization Blog Post Gist
#### Load Data Set ####
# You need to download this data by yourself.
# See https://data.cityofnewyork.us/Public-Safety/NYPD-Motor-Vehicle-Collisions/h9gi-nx95
collision <- fread('NYPD_Motor_Vehicle_Collisions.csv', stringsAsFactors = F)
# Transform Date & Time (rounded to hour)
work_dt <- collision %>%
mutate(FULLDATE = as.POSIXct(paste(DATE, TIME),
format = '%m/%d/%Y %H:%M',
tz = 'EST')
) %>%
mutate(YEAR = year(FULLDATE),
MONTH = month(FULLDATE),
DAY = mday(FULLDATE),
HOUR = hour(round(FULLDATE, 'hour'))
) %>%
as.data.table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment