R/in.R

Defines functions nin yin

Documented in nin yin

#' Return lhs values not in rhs values
#'
#' @param lhs Values to check whether they are/not contained in the other
#' @param rhs Values to use as the reference
#' @param value Logical indicating whether to return the value or a logical vector
#' @examples
#'
#' ## a, b, zz in alphabet letters
#' yin(c("a", "b", "zz"), letters)
#'
#' ## a, b, zz NOT in alphabet letters
#' nin(c("a", "b", "zz"), letters)
#'
#' @export
nin <- function(lhs, rhs, value = TRUE) {
  x <- !lhs %in% rhs
  if (value) {
    x <- lhs[x]
  }
  x
}

#' @inheritParams nin
#' @rdname nin
#' @export
yin <- function(lhs, rhs, value = TRUE) {
  x <- lhs %in% rhs
  if (value) {
    x <- lhs[x]
  }
  x
}

Try the tfse package in your browser

Any scripts or data that you put into this service are public.

tfse documentation built on May 2, 2019, 11:28 a.m.