R/setdiff3.R

Defines functions setdiff3

Documented in setdiff3

#' Three-way [setdiff()] of two collections
#'
#' @param a A collection of R objects.
#' @param b A collection of R objects.
#'
#' @return A list with objects only in `a`, only in `b`,
#'   and in both collections.
#' @export
setdiff3 <- function(a, b) {
  nm_a <- deparse(substitute(a))
  nm_b <- deparse(substitute(b))
  out <- list(setdiff(a, b), setdiff(b, a), intersect(a, b))
  names(out) <- c(nm_a, nm_b, "both")
  out
}
tomshafer/tshfr documentation built on Sept. 27, 2022, 2:42 p.m.