R/not_in.R

Defines functions not_in

Documented in not_in

#' Checks if an item is part of the related list
#'
#' @description
#' The not_in function returns the logical inverse of the in operator from "in"
#'    pairs well with `magrittr` (i.e., `%>%`) to allow for pipe operations
#'
#' "in" is currently defined as
#'
#' function(x, table) match(x, table, nomatch = 0) > 0
#'
#' @param x vector or NULL: the values to be matched. Long vectors are supported
#' @param y vector or NULL: the values to be matched against. Long vectors are not supported.
#'
#' @seealso match which this function wraps
#'
#' @return The the logical inverse of x %in% y
#'
#' @examples
#'   not_in("c", c("c", "a", "t", "s")) # is false
#'   not_in("c", c("d", "o", "g", "s")) # is true
#'
#' @export
not_in <- function(x, y) {
  !('%in%'(x,y))
}
bcbeidel/notin documentation built on Nov. 3, 2019, 2:08 p.m.