# ---------------------------------------------------------------------------- #
#' Find non-matching values
#'
#' Returns non-matching values for its left operand when compared to the right
#' operand.
#'
#' @name notin
#'
#' @param x A vector or NULL: values to be compared.
#' @param y A vector or NULL: values for which \emph{non}-matches should be
#' returned.
#'
#' @return A logical vector indicating if there is \emph{no} match for its left
#' operand.
#'
#' @examples
#' foo <- letters[1:6]
#' foo[foo %notin% c("a", "c", "e")]
#' # => [1] "b" "d" "f"
#'
#' lst <- list(a = 1, b = 2, c = 3, d = 4)
#' lst[names(lst) %notin% c("a", "c", "d")]
#' # =>
#' # $b
#' # [1] 2
#'
#' NULL %notin% c(1, 2)
#' # => logical(0)
#'
#' c("a", "b", "c") %notin% NULL
#' # => [1] TRUE TRUE TRUE
#'
#' @export
#'
`%notin%` <- function(x, y) {
# See
# http://stackoverflow.com/questions/7494848/
# standard-way-to-remove-multiple-elements-from-a-dataframe
# [viewed 09jan20]
!(x %in% y)
}
# ---------------------------------------------------------------------------- #
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.