Vehicle Crashes - Polson, MT 2018 - 2022


Ben Sundy
Geog 588 HW3
2024/03/12

Introduction

In this report, I explore data obtained by the Montana Department of Transportation regarding vehicle crashes in Polson montana from 2018 - 2022. You can request your own crash data from Montana Department of Transport.


Begin Exploring the Data

I begin my project by loading my libraries…
#load libraries ---------
library(tidyverse)
library(here)
library(ggbeeswarm)


… and then loading my dataset.

#read in data ----------
plotcrashes <- read_csv(here("Data/HW3",  "polsoncrashes_new.csv")) # Polson,MT Vehicle crashes 2018-2022


Next, I will take a glimpse at my data in order to understand how the the data is structured and organized. Understanding the variables is necessary in order to ask meaningful questions about the data to gain meaningful insights.

#take a glimpse at your data
glimpse(plotcrashes)
## Rows: 485
## Columns: 95
## $ crash_id                                    <chr> "T015-00635", "T015-00558"…
## $ corridor_name                               <chr> "C000005", "C024204", "C07…
## $ reference_post_and_offset                   <chr> "054+0.980", "000+0.006", …
## $ city_name_from_crash_report                 <chr> NA, NA, "Polson", NA, "Pol…
## $ county_name_from_crash_report               <chr> "Lake", "Lake", "Lake", "L…
## $ crash_date                                  <chr> "11/23/2022", "12/27/2018"…
## $ month                                       <dbl> 11, 12, 5, 5, 5, 2, 12, 11…
## $ day                                         <dbl> 23, 27, 17, 12, 7, 7, 14, …
## $ year                                        <dbl> 2022, 2018, 2018, 2018, 20…
## $ crash_time                                  <time> 01:45:00, 10:11:00, 17:24…
## $ day_of_week                                 <chr> "WED", "THU", "THU", "SAT"…
## $ collision_type                              <chr> "Fixed Object", "Rear-End"…
## $ junction_relation                           <chr> "Non-Junction", "Intersect…
## $ crash_severity                              <chr> "No apparent Injury (prope…
## $ relation_to_traffic_way                     <chr> "Roadside Right", "On Road…
## $ weather                                     <chr> "Clear", "Snow", "Cloudy",…
## $ road_surface_condition                      <chr> "Ice/Frost", "Snow", "Dry"…
## $ lighting_condition                          <chr> "Dark-Not Lighted", "Dayli…
## $ num_fatalities                              <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ num_inuries                                 <dbl> 0, 0, 1, 1, 0, 0, 0, 0, 0,…
## $ num_of_vehicles                             <dbl> 1, 2, 1, 1, 2, 1, 2, 2, 2,…
## $ num_occupants                               <dbl> 1, 2, 1, 1, 2, 1, 2, 2, 2,…
## $ num_of_pedestrians                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ non_motorist                                <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ first_harmful_event_type                    <chr> "Collision With Fixed Obje…
## $ first_harmful_event_within_interchange_area <chr> "No", "No", "No", "No", "N…
## $ first_harmful_event_detail                  <chr> "Fence", "Motor Vehicle In…
## $ contributing_circumstances_environment_1    <chr> "Weather Conditions", "Wea…
## $ contributing_circumstances_environment_2    <chr> "None", "Weather Condition…
## $ contributing_circumstances_environment_3    <chr> "None", "Weather Condition…
## $ contributing_circumstances_road_1           <chr> "Road Surface Condition (W…
## $ contributing_circumstances_road_2           <chr> "None", "Road Surface Cond…
## $ contributing_circumstances_road_3           <chr> "None", "Road Surface Cond…
## $ officer_description                         <chr> "HIGHWAY 93 S OF N RESERVO…
## $ crash_intersecting_roadway                  <chr> "NORTH RESERVOIR ROAD", "U…
## $ crash_intersection_distance_from_crash      <dbl> 200, 0, 0, 0, 0, 0, 0, 18,…
## $ intersection_direction_from_crash           <chr> "S", "N", NA, NA, NA, NA, …
## $ intersection_type                           <chr> "Not At Intersection", "T-…
## $ traffic_control_device_type                 <chr> "Railway Signal Lights And…
## $ pedestrian_bicycle                          <chr> "No", "No", "No", "No", "N…
## $ wild_animal_related                         <chr> "No", "No", "No", "No", "N…
## $ school_bus_related                          <chr> "No", "No", "No", "No", "N…
## $ hit_and_run_id                              <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ mdt_impaired_driver                         <chr> "No", "No", "Yes", "Yes", …
## $ site_study_indicator                        <chr> "No", "No", "No", "No", "N…
## $ site_study_request                          <chr> "No", "No", "No", "No", "N…
## $ site_study_recommendations                  <chr> NA, NA, NA, NA, NA, NA, NA…
## $ rail_road_crossing_id                       <lgl> NA, NA, NA, NA, NA, NA, NA…
## $ railway_grade_crossing_related              <chr> "No", "No", "No", "No", "N…
## $ train_vehicle_collision_related             <chr> "No", "No", "No", "No", "N…
## $ commercial_vehicle_involved                 <chr> "No", "No", "No", "No", "N…
## $ commerical_Vehicles                         <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ work_zone_related_crashes                   <chr> "No", "No", "No", "No", "N…
## $ work_zone_activity_type                     <chr> NA, NA, NA, NA, NA, NA, NA…
## $ work_zone_related_location_of_crash         <chr> NA, NA, NA, NA, NA, NA, NA…
## $ work_zone_worker_present                    <chr> NA, NA, NA, NA, NA, NA, NA…
## $ work_zone_law_enforcement_present           <chr> NA, NA, NA, NA, NA, NA, NA…
## $ district_from_crash_report                  <chr> NA, "Missoula", "Missoula"…
## $ financial_district_from_crash_report        <chr> "Missoula", "Missoula", "M…
## $ reservation                                 <chr> "Flathead", "Flathead", "F…
## $ govt_owner                                  <chr> "State Highway Agency", "I…
## $ system_class                                <chr> "Ninhs", "Off System", "Of…
## $ location_type                               <chr> "On System", NA, "City", N…
## $ functional_class                            <chr> "Principal Arterial - Othe…
## $ aadt_crashes                                <dbl> 10826, 128, 60, 128, 60, 6…
## $ percent_growth                              <dbl> 1, 0, 0, 0, 0, 0, 1, 0, 0,…
## $ truck_aadt                                  <dbl> 328, 0, 0, 0, 0, 0, 0, 0, …
## $ percentage_truck                            <dbl> 4.4, 0.0, 0.0, 0.0, 0.0, 0…
## $ speed_limit                                 <dbl> 65, 70, 25, 35, 25, 25, 25…
## $ roadway_bikeway_facility                    <chr> "Marked Bicycle Lane", "Se…
## $ urban_rural                                 <chr> "Rural", "Rural", "Rural",…
## $ grade                                       <chr> "Road is straight: level",…
## $ number_of_lanes                             <dbl> 4, 2, 2, 2, 2, 2, 2, 2, 2,…
## $ shoulder_width                              <dbl> 8, 0, 0, 0, 8, 8, 8, 1, 4,…
## $ terrain_surface                             <chr> "Rolling_Tar And Gravel", …
## $ road_surface_type                           <chr> "Tar And Gravel", "Tar And…
## $ terrain_type                                <chr> "Rolling", NA, NA, NA, NA,…
## $ township_code                               <chr> "22N", "22N", NA, NA, NA, …
## $ range_code                                  <chr> "20W", "20W", NA, NA, NA, …
## $ section_code                                <dbl> 25, 25, NA, NA, NA, NA, 4,…
## $ accumulated_mile_offset                     <dbl> 54.98028, 0.00639, 0.11322…
## $ x_coordinate                                <dbl> 253729.8, 253783.6, 251131…
## $ y_coordinate                                <dbl> 387439.8, 387508.1, 392130…
## $ gn_intersection_id                          <dbl> 0, 44150, 0, 0, 0, 0, 0, 0…
## $ gn_intersection_name                        <chr> NA, "N-5 & N-5", NA, NA, N…
## $ gn_corridor_1                               <chr> NA, "C000005A", NA, NA, NA…
## $ gn_ref_post_corridor_1                      <chr> NA, "055+0.499", NA, NA, N…
## $ gn_functional_class_1                       <dbl> NA, 3, NA, NA, NA, NA, NA,…
## $ gn_corridor_2                               <chr> NA, "C000005D", NA, NA, NA…
## $ gn_ref_post_corridor_2                      <chr> NA, "055+0.025", NA, NA, N…
## $ gn_functional_class_2                       <dbl> NA, 3, NA, NA, NA, NA, NA,…
## $ logaadt_crashes                             <chr> "9.289705927", "4.85203026…
## $ aadt_crashdiff                              <dbl> NA, -10698, -68, 68, -68, …
## $ morecrash                                   <lgl> TRUE, FALSE, FALSE, FALSE,…
## $ morecrash_collision                         <lgl> TRUE, FALSE, FALSE, FALSE,…


Create Plots and Graphs

I must confess, I am not a stats guy or a math man. In fact, one of my motivations for pursuing more education was to sharpen my analytic skills. When I originally sourced this data for the lesson1 homework, I thought it would be perfect. By lesson two, I realized it was not great for any sort of quantitative analysis. The most interesting variables to me include crash date, crash time, crash severity, number of vehicles, number of occupants, and weahter. I think the largest number in occupants involved in a sigle crash is ten, and the largest number of vehicles involved in a single accident is 4. This doesn’t make for very interest means or really present any outliers. Beyond that, there were many variables tha were simply yes or null. Preparing the data reuired skills beyond what we learned in our tidying up lesson. With that being said, by analyzing the variables identified above, I hope to be able to gain insights into the dataset. For instance, do more crahes occur more in the morning or evening? Do more crashes occur on clear or rainy days? Do more crashe occur in single occupancy vehilces or in vehicles with multiple passengner? Lets dive in and see what we can find out!


#create pie chart
plotcrashes %>%
  ggplot(aes(x = "", y = crash_severity, fill = crash_severity)) +
  geom_bar(stat="identity") +
  coord_polar("y", start=0) +
  theme_void() +
  labs(title = "Crash Severity Pie Chart",
       fill = "Crash Severity")

###### exported .png from RStudio inserted into report! —

#plot severity of crashes by day
plotcrashes %>%
  ggplot(aes(x = day_of_week, y = num_of_vehicles, color = crash_severity)) +
  geom_jitter()  +
  coord_flip() +
  facet_wrap(~ crash_severity) +
  labs(title = "Crashes/Number of Vehicle",
       subtitle = "broken down by severity",
       x = "Day of the Week",
       y = "Total # of Vehicles Involved")


#create a bar chart
plotcrashes %>%
  ggplot(aes(x = year, color = crash_severity, fill = crash_severity)) +
  geom_bar() +
  labs(title = "Bar Chart of Vehicle Crashes",
       legend = "Crash Severity",
       x = "Year",
       y = "Count") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))


Conclusions

This has been a fun way to dip my toes into visualizing data with R. It’s worth noting that Polson, MT is a small and rural town in Western, MT with several factors that make it unique. It is on the Flathead Indian Reservation, is a vacation destination, and is halfway between a National Park and a the second largest city in in the state. For these reasons, I feel like my dataset might not tell the whole story about vehicle accidents. I wish the dataset had information about whether a driver was a resident of Polson, a resident of MT, or an out of state tourist. Unfortunately, I do not think that is information the Montana Department of Transportation keeps track of and thusly I will need to keep my questions relevant to the information detailed in the dataset.