I'm wondering how to subset (or filter) a data frame by two columns (one is string, one is number) including only results where both conditions are met, not one or the other.
If I use the & operator, it returns data where either condition is met.
foo <- iris[which(iris$Petal.Length > 1.2 & iris$Species != "setosa"),]
We can try
library(data.table) as.data.table(iris)[Species == "setosa" & Petal.Length> 1.2| Species != "setosa" & Petal.Length > 1.2]
iris %>% filter(Species == "setosa" & Petal.Length > 1.2 | Species != "setosa" & Petal.Length > 1.2)