I have the following data frame:
structure(list(Species = 1:4, Ni = c(1, NA, 1, 1), Zn = c(1,
1, 1, 1), Cu = c(NA, NA, 1, NA)), .Names = c("Species", "Ni",
"Zn", "Cu"), row.names = c(NA, -4L), class = "data.frame")
and I would like to get a vector containing all the species where Ni = 1, Zn = 1 and Cu = NA. So in this example that would be (1,4)
I thought I could have a try with the R script select * from where, but I can’t seem to install the package RMySQL on RStudio (R version 2.15.1).
Rather than using
Ni == 1you should useNi %in% 1, as the former will returnNAelements whereNiisNA.Cu %in% NAproduces the same result asis.na(Cu).Note though that
Ni == 1used insubset, as in @MadScone’s answer, does not suffer from this (which came as a surprise to me).