I've been trying to replace multiple strings in a column of a data frame in R using str_replace_all.
Currently I've written up something simple for now (below)
mydata$Final_Result <- str_replace_all(mydata$Final_Result, 'Absent', 'A')
mydata$Final_Result <- str_replace_all(mydata$Final_Result, 'Present', 'P')
I have other strings to replace in the same column. So I am looking for a more elegant way to write this code in a single line.
Would appreciate if anyone could advise on how this can be done.