df = data.frame("a" = c(1, 2, 3, "q", "r"),
"b" = c(5,6,7,0,"s"))
dfWANT = data.frame("a" = c(1, 2, 3, "NA", "NA"),
"b" = c(5,6,7,0,"NA"))
REP = c("q", "r", "s")
df[,][df[,] == REP] <- NA
I aim to specify a list(REP
) that has the scores I want to set to NA
. Original data is df
and the one I want is dfWANT
. REP
is the vector of values I want to set to NA
and the last line is my attempt that works only on col a.