Hello,
I have a data frame with a string column. All data that are neither
"POS" nor "NEG" should've replaced by an NA. How can I implement that
(even with extra libraries)? My attempts actually wipe out POS and
NEG...
Thank you
```
df = data.frame(a = 1:5, b = c("", "31.35", "POS", "20.61", "NEG"),
stringsAsFactors = F)
df$b[!(df$b == "POS") & (df$b == "NEG")] = NA
df$b[(df$b == "POS") | (df$b == "NEG")] = NA
```
--
Best regards,
Luigi
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.