Possible duplicate:Removing specific rows from a data frame
Using R, how can I write the following logic into a data frame: IF column A = B and column E = 0, delete the row
Logical index:
d<-d[!(d$A=="B" & d$E==0),]
A subset is your safest and easiest answer.
subset(dataframe, A==B & E!=0)
Real-world example using mtcars
subset(mtcars, cyl==6 & am!=0)
Use which function:
A <- c('a','a','b','b','b') B <- c(1,0,1,1,0) d <- data.frame(A, B) r <- with(d, which(B==0, arr.ind=TRUE)) newd <- d[-r, ]