%nin% | R Documentation |
%nin%
finds non-matching elements in a given vector. It is the negation of %in%
.
a %nin% b
a |
a vector (character, factor, or numeric) |
b |
a vector (character, factor, or numeric) |
This is a simple negation of %in%
. I use it mostly for columns in a data frame.
%nin%
finds non-matching elements and returns one of two things, depending on the use. For two simple vectors,
it will report what matches and what does not. For comparing a vector within a data frame, it has the effect of reporting the rows
in the data frame that do not match the supplied (second) vector.
library(tibble)
library(dplyr)
# Watch this subset stuff
dat <- tibble(x = seq(1:10), d = rnorm(10))
filter(dat, x %nin% c(3, 6, 9))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.