Bad weather causes bad accident

  • A weather-related accident is defined as one that occurs in any adverse condition such as sleet, snow, rain, fog, winds or on slick pavement.If you want to know how bad weather increases driving accidents, please click here.

Number of Accident by Degree of Precipitaion over a day

daily_weather_collision = daily_weather_collision %>%
   mutate(hour = factor(hour, levels = c(0:23)))
daily_weather_plot = function(i){
daily_weather_collision %>% 
  filter(prep_degree == i) %>%
  filter(type == "accident") %>%
  ggplot(aes(x = hour, y = number, color = hour)) +
  geom_boxplot(alpha = 0.5) + 
  labs(
    color = "type",
    title = sprintf("Accident Number when rain is %s",i),
    y = "Accident Number",
    x = "Hour"
    ) +
  ylim(0,100) +
    theme(legend.position = "none")}
saveGIF({
  for (i in c("light","moderate","heavy"))
  {
    print(daily_weather_plot(i))
  }
}, movie.name = "weather.gif", ani.width = 700, ani.height = 600
)

Comments:

Extreme accidents happen during heavy/moderate precipitation as compared to light precipitation, which match our original hypothesis. If you go out and drive when rain is heavy, be careful, the possibility that huge collision happens also increases.

Number of Accident by Weather

weather_type_plot =  
collision_weather %>% 
  group_by(weathertype) %>% 
  summarise(
    count = mean(collision_event)
  ) %>% 
  mutate(
    weathertype = fct_reorder(weathertype,count)
  ) %>% 
  ggplot(aes(x = weathertype, y = count,
             fill = weathertype)) + 
  geom_bar(stat = "identity", width = 0.6) +
  coord_flip()+
  labs(
    title = " Number of Accident by weather",
    y = "Number of Accident",
    x = "Weather Type"
    )
ggplotly(weather_type_plot) %>% 
  layout(legend = list(orientation = "h",   # show entries horizontally
                     x = 0.3, y = -0.2))  

Comments:

It is surprising to see that sunny weather is the third most common weather type when car accidents tend to happen. On the other hand, people might be going outside more on sunny days, which can cause an increase in car accidents. Accident number in this plot is strongly related to how likely people will go out under different weather conditions. More people being outside means more accidents.