Recode vehicle type

tc_recode_vehicle_type(
  x,
  pattern = c(`Taxi*.+` = "Taxi", `Van*.+` = "Van", `Pedal cycle` = "Bicycle",
    `(M|m)otorcycle*.+|Elec*.+` = "Motorcycle",
    `Data*.+|Other*.+|Agri*.+|Ridden*.+|Mobility*.+|Tram*.+` = "Other", `Bus*.+` = "Bus",
    `Minibus*.+` = "Other", `Goods*.+` = "HGV")
)

Arguments

x

Character string to recode

pattern

A named character vector with values representing new values. Has the form c("Car long name" = "Car", "Taxi/Private hire car" = "Taxi"). Car long name will be converted into Car in this case.

See also

tc_recode

Examples

(x = stats19::vehicles_sample$vehicle_type)
#> [1] "Car"                           "Goods 7.5 tonnes mgw and over"
#> [3] "Car"                          
tc_recode_vehicle_type(x)
#> [1] "Car" "HGV" "Car"
if (FALSE) {
v = stats19::get_stats19(2018, "vehicles")
v$vehicle_type_simple = tc_recode_vehicle_type(v$vehicle_type)
table(v$vehicle_type)
table(v$vehicle_type_simple)
}