I simplified the data df for demonstration purpose.
df<-data.frame(id=c(1,1,3,4,5,6,7),title_1=c("H","M","","M","L","L","H")
,title_2=c("M","M","","L","L","L","H")
,title_3=c("H","H","M","L","","M","M"))
what I want to do is change the values.If the value is null "", then I want to change it to 0.
If the value is H, I want to change it to 3. If the value is M, I want to change it to 2.
If the value is L, I want to change it to 1. The reason why I stuck here is because in my actual data, there are so many columns named as titel_1, title_2,title_3, ... ,title_100.So, I cannot type every columns to do this . So I need the code that is applicable to the data that has many columns.