I have a dataframe df with a series of NA and strings and 2 matrices match and value with same ncol and nrow. match has all the possible strings in df
I would like to replace the strings in df with those in value. If a string in df matches the values in match, then it can be replaced by the string in value at the same position
I believe the first step is to create a new df with the position of match in df
df1 <- which(df %in% match) #nothing valuable...
apologies for less code from my side.
df <- as.data.frame(matrix(c("ab","bc",NA,"aa",NA,NA,"de","aa",NA,"bc","ab","ab"),ncol = 4))
match <- matrix(c("ab","bc","de","aa"),nrow = 2)
value <- matrix(c("Good","Bad","Average","Stop"),nrow = 2)
output <- as.data.frame(matrix(c("Good","Bad",NA,"Stop",NA,NA,"Average","Stop",NA,"Bad","Good","Good"),ncol = 4))
plyr:matrix(mapvalues(unlist(df),c(match),c(value)),dim(df))