Example using mtcars:
data(mtcars)
mtcars$car <- row.names (mtcars)
In car column: I have car names listed as "Mazda RX4", "Mazda RX4 Wag", "Datsun 710", "Hornet 4 Drive", etc. Assume I wanted to remove the model of the car and only leave the manufacturer e.g. "Mazda", "Datsun", "Hornet", also assume that the names are not formated to have manufacturer always as the first word, so I can also have a name for the car as "ModelX Mazda", or "model Tesla XX", so I cant extract manufacturer as the first word of a string.
How would you go about this task, if you had a string that contained all the manufacturers names c("Mazda", "Datsun", "Hornet")?