Posting an image of data is much less helpful than posting the output of dput because it requires others to manually enter your data. I invented a tiny set of data to test my code.
library(dplyr)
library(stringr)
DF <- data.frame(Asset.Description=c("Big Crane","Skid Loader 567",
"341T Water Tanker"))
DF <- DF |> mutate(Category=case_when(
str_detect(Asset.Description, "Pipe Loader") ~ "Pipe Loaders",
str_detect(Asset.Description, "Crane") ~ "Cranes",
str_detect(Asset.Description, "Bus") ~ "Buses",
str_detect(Asset.Description, "Ambulance") ~ "Ambulance",
str_detect(Asset.Description, "Compressor") ~ "Compressors",
str_detect(Asset.Description, "Bucket Loader") ~ "Bucket Loaders",
str_detect(Asset.Description, "Forklift") ~ "Forklifts",
str_detect(Asset.Description, "Generator") ~ "Generatorss",
str_detect(Asset.Description, "Light Tower") ~ "Light Towers",
str_detect(Asset.Description, "Skid Loader") ~ "Skid Loaders",
str_detect(Asset.Description, "Stacker") ~ "Stacker",
str_detect(Asset.Description, "Tractor Head") ~ "Tractor Head",
str_detect(Asset.Description, "Water Tanker") ~ "Water Tanker",
str_detect(Asset.Description, "Welding Machine") ~ "Welding Machine",)
)
DF
#> Asset.Description Category
#> 1 Big Crane Cranes
#> 2 Skid Loader 567 Skid Loaders
#> 3 341T Water Tanker Water Tanker
Created on 2022-01-27 by the reprex package (v2.0.1)