df1=c("blue,green,green", "blue", "green")
dictionary=data.frame(label=c("blue","green"),value=c(1,2))
want=c("1,2,2","1","2")
I am looking to replace some data using a data dictionary. The data (df1) may have multiple entries in one cell, separated by a comma. I have looked at str_replace_all and I was able to do so bystr_replace_all(colors,c("blue"="1","green"="2")) but I was unable to create c("blue"="1","green"="2") using the dictionary data frame. I have over a hundred items to code so hard coding is not an option.
Any guidance on how to make that work or another way around would be greatly appreciated!