Skip to content

Instantly share code, notes, and snippets.

@yeere91
Created October 24, 2016 05:46
Show Gist options
  • Save yeere91/380563a838521a88e9f846aa412b05d2 to your computer and use it in GitHub Desktop.
Save yeere91/380563a838521a88e9f846aa412b05d2 to your computer and use it in GitHub Desktop.
############### By Time
# We want to organize the crashes by hours
date_hour = strptime(vehc$TIME,"%H")
hour = as.numeric(format(date_hour, "%H")) +
as.numeric(format(date_hour, "%M"))/60
vehc$hour = hour
common_times = vehc %>% group_by(hour) %>%
summarize(count=n()) %>%
arrange(desc(count))
##Barchart of the common times of car crashes in the entire dataset.
g_hour=ggplot(data=common_times)
g_hour+geom_bar(aes(x=hour, y=count),stat="identity")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment