A toy example:
> dfx <- data.frame(a=c("A","X","X","D","X",NA,NA),b=c(1,3,4,5,2,1,NA))
> dfx[dfx$a=="E",]
a b
NA <NA> NA
NA.1 <NA> NA
Why R gives the NA rows for a value that do not exist?
It is very dangerous to do things like (when you believed that "E" exists in dfx):
> nrow(dfx[dfx$a=="E",])
[1] 2
Thanks!