I have a dataframe and in the column "roles", each row has a value of "students" or "teacher". I want to replace these values with "st" or "te" accordingly.
roles_complete <- c("students","teacher")
roles_standard <- c("st", "te")
data$roles <- stri_replace_all(data$roles, regex= roles_complete, roles_standard)
Weirdly, this only changes some values.
roles
1 st
2 students
3 teacher
4 te
5 st
6 students
7 teacher
8 te
9 st
10 students
11 teacher
12 te
I'm obviously doing something wrong with the conditions I've inserted in the stri_replace but the documentation is not very clear.