how can I group elements of a variable by common patterns. for example I have a database in which there is a field called company role and I would like to be able to group the common roles into one.
employee <- c("a", "b", "c", "d", "e")
Rol <- c(" accounting assistant", "accou assist", "account.assistant",
"healt aux", "auxiliary in healt")
DF <- data.frame(employee, Rol)
I would like to transform it into something like this
Employeee | ROL |
---|---|
A | accounting assistant |
B | accounting assistant |
C | accounting assistant |
D | Healt auxiliary |
E | Healt auxiliary |
At the moment i'm manually indentifying the patterns but as the data grows the task becomes more complex, i'd appreciate any help. Thanks!