Description Usage Arguments Value Examples
This operator is simply the inverse of the native %in%
operator, and will
return true if the left-hand side is not in the right hand side. See the
examples for more details.
1 | x %nin% table
|
x |
vector or |
table |
vector or |
A logical vector indicating if a match was not located for each
element of x
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | best_cats <- c("Tucker", "Oliver", "Mr. Loon")
# Returns TRUE, obviously
"Tucker" %in% best_cats
# Returns FALSE (because Tucker is the best cat)
"Tucker" %nin% best_cats
# Create a vector of vowels
vowels <- c("a", "e", "i", "o", "u")
# Create a sentence
sentence <- "Sushi is great!"
# Split sentence into individual letters
sentence_letters <- strsplit(sentence, "")[[1]]
# Subset the sentence for all vowels
sentence_letters[sentence_letters %in% vowels]
# Subset the sentence for all consonants
sentence_letters[sentence_letters %nin% vowels]
# Vector of numbers 1 through 10
all_nums <- seq(0,10)
# Vector of a few numbers between 1 through 10
sub_nums <- c(1,3,6)
# Which numbers between 1 and 10 are in the subset
all_nums[all_nums %in% sub_nums]
# Which numbers between 1 and 10 are not in the subset
all_nums[all_nums %nin% sub_nums]
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.