Recode casualty_type variable from STATS19 data
tc_recode_casualties(x, pattern = NULL, pattern_match = casualties_lookup)
x | Character string to recode |
---|---|
pattern | A named character vector with values representing new values.
Has the form |
pattern_match | Character string in the form of
|
(x = stats19::casualties_sample$casualty_type) #> [1] "Motorcycle 125cc and under rider or passenger" #> [2] "Pedestrian" #> [3] "Car occupant" tc_recode_casualties(x) #> [1] "Motorcyclist" "Pedestrian" "Car_occupant" if (FALSE) { cas = stats19::get_stats19(2018, "casualties") cas$casualty_type_simple = tc_recode_casualties(cas$casualty_type) table(cas$casualty_type) table(cas$casualty_type_simple) }