setdiff2: A dual-direction, fast (and dangerous!) version of setdiff.

Description Usage Arguments Details Value Examples

View source: R/properties.R

Description

setdiff() is not symmetric. This function returns a list with component 1 equivalent to setdiff(x, y) and component 2 equivalent to setdiff(y, x).

Usage

1
  setdiff2(x, y)

Arguments

x

A numeric vector

y

A numeric vector

Details

Note that unlike setdiff() THE OUTPUT MAY CONTAIN DUPLICATES. eg setdiff2(c(1,1,2), c(2, 3))[[1]] == c(1, 1) BUT setdiff(c(1, 1, 2), c(2, 3)) == 1

Additionally the inputs are NOT coerced to vectors, again, unlike setdiff

Value

A list of length 2, with setdiff(x, y) in component 1 and setdiff(y, x) in component 2 (apart from the differences described above).

Examples

1
2
setdiff2(c(1,1,2), c(2, 3))[[1]]
setdiff(c(1, 1, 2), c(2, 3))

rjbgoudie/parental documentation built on May 27, 2019, 9:11 a.m.