Add strike and casualty distances to injury tables
Source:R/add_distance_columns.R
add_distance_columns.Rd
This function adds strike and casualty distance information for both individual age and sex categories and aggregated by mode to both the who-hit-whom (whw) and no-other-vehicle (nov) injury fatality matrices.
Arguments
- injury_table
(list of) data frame(s) to be edited, contains aggregated fatality counts split into whw and nov matrices
- mode_names
which modes to take distances for, taken from the aggregated modes in the trip data
- true_distances_0
population distances to add to injury table
- dist
table used to access bus distance - not currently used
- scenarios
which scenarios to process
Details
The function performs the following steps:
set up a dataframe containing all the age and sex categories found in the injury table input data
add age and sex index to mode distances
define a list with two elements for whw and nov with the same indices used in the true_distances dataframe for all age and sex categories
define a list (with two elements for whw and nov) matching the indices of the mode_names with the casualty modes in the injury table
for the whw matrix create a strike mode indices vector matching the strike modes in the injury table with the strike_modes vector
find the strike and casualty distances for all modes in the injury tables both as sum across all age and sex categories and for each individual age and sex category. For modes that exist in the injury tables for which we have no known distances, the mean mode distances of the known modes is used
add the strike and casualty modes to the whw and nov matrices in the injuries_list output list