I want to do a similar thing as in this thread: Subset multiple columns in R - more elegant code?
I have data that looks like this:
df=data.frame(x=1:4,Col1=c("A","A","C","B"),Col2=c("A","B","B","A"),Col3=c("A","C","C","A"))
criteria="A"
What I want to do is to subset
the data where criteria
is meet in at least two columns, that is the string
in at least two of the three columns is A
. In the case above, the subset
would be the first and last row of the data frame df
.