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") )
x | Character string to recode |
---|---|
pattern | A named character vector with values representing new values.
Has the form |
tc_recode
(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) }