I have a dataframe like this
M2 <- matrix(c(1,0,0,1,1,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0),nrow=7,
dimnames=list(LETTERS[1:7],NULL))
I would like to select the rows based on multiple columns. For instance when I want to select rows based on only two columns, I did
ans<-M2[which(M2[,1]==0 & M2[,2]==0)
But when I want to select only those rows which have value zero based on three or four columns, say based 1, 3, and 4 th column or say 1, 2,3, 4 , how do I do this?
whichhere. Isans<-M2[M2[,1]==0 & M2[,2]==0 & M2[,4]==0,]sufficient for your needs?