Вы можете использовать subset
и включить условие.
subset(df, Col2 != 0 & Col3 != 0 & (Col2 + Col3) != (1- Col2))
#In this case this gives the same answer
#subset(df, Col2 != 0 & Col3 != 0)
# Col1 Col2 Col3
#3 G3 2 1
#6 G6 3 4
Или используя его в dplyr::filter
library(dplyr)
df %>% filter(Col2 != 0 & Col3 != 0 & (Col2 + Col3) != (1- Col2))
data
df <- structure(list(Col1 = structure(1:6, .Label = c("G1", "G2", "G3",
"G4", "G5", "G6"), class = "factor"), Col2 = c(0L, 1L, 2L, 2L,
0L, 3L), Col3 = c(1L, 0L, 1L, 0L, 2L, 4L)), class = "data.frame",
row.names = c(NA, -6L))