I have character vector (column) in a data.frame that contains three correct values comprised of "Positive", "Negative" and NA, along a small number of incorrect values. I want to replace the incorrect values, i.e. everything except "Positive", "Negative" and "NA" with "Positive" I can grep for NOT "Positive" or "Negative", using grep and the invert=TRUE argument, and get everything except instances of "Negative" and "Positive" but I've not figured out how to additionally, not replace any instances of NA. I've also looked at the sub command, but it does not have an invert option. Any suggestions?
Asked
Active
Viewed 1,026 times
0
-
2Please read the info about how to give a [minimal reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610). – Jaap Oct 14 '15 at 15:01