%ni% | R Documentation |
This returns TRUE
if values are not in a list. It's the opposite
of %in%
. This is particularly good when subsetting and you only want
to remove a few things (like diphthongs). You can remove those rather than
specifying all monophthongs you want to keep.
x %ni% y
x |
A vector, presumably a subset of "y" |
y |
A vector |
Note that what this function does can easily be accomplished with !x %in% y
,
but I like the "not in" aspect. Probably a holdover from my Perl days...
You can also define this function as `%ni%` <- Negate(`%in%`)
but
when looking through the documentation on %in%, I found that it might be
better to modify the formal definition there instead.
Credit to this Stack Overflow question for showing how to get this to work in an R package.
A list of logicals indicating whether the objects in x
are not
contained in y
.
1:10 %in% c(1,3,5,9)
1:10 %ni% c(1,3,5,9)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.