Possible Duplicate:
Opposite of %in%
What is the opposite of
matrix[matrix%in%1,]?
!%in% does not work.
I would like to select items that do not contain a certain number.
Possible Duplicate:
Opposite of %in%
What is the opposite of
matrix[matrix%in%1,]?
!%in% does not work.
I would like to select items that do not contain a certain number.
If you find yourself using @Joshua's suggestion often, you could easily make your own %notin%
operator.
`%notin%` <- Negate(`%in%`)
'a' %notin% c('b', 'c')
# [1] TRUE
You want:
matrix[!matrix %in% 1,]
For clarity's sake, I prefer this, even though the parentheses aren't necessary.
matrix[!(matrix %in% 1),]
Also note that you need to be aware of FAQ 7.31: Why doesn't R think these numbers are equal?.