sym.diff: Compute the symmetric difference between two vectors.

Description Usage Arguments Details Examples

Description

R's base setdiff function does a one-way set difference, e.g. setdiff(x, y) = x - y. More often than not, I'm wondering what values are different between x and y – both ways. Hence, symmetric difference. Full disclosure: I copied the core of this function from the following StackOverflow post, with some basic tidying for interactive analysis.

Usage

1

Arguments

x

one of the two vectors (soon-to-be sets) of interest

y

one of the two vectors (soon-to-be sets) of interest

pretty

boolean denoting whether we should also output the one- and two-sided set differences. More appropriate for interactive analyses.

Details

Source: https://stackoverflow.com/questions/19797954/function-to-find-symmetric-difference-opposite-of-intersection-in-r

Examples

1
2
3
4
5
# Find out what differences there are between 1:10 and 5:15
sym.diff(1:10, 5:15) # `1, 2, 3, 4, 11, 12, 13, 14, 15`

# Verbose output version:
sym.diff(1:10, 5:15, pretty = TRUE) # Output one- and two-sided set difference

dataframing/archive documentation built on May 20, 2019, 10:19 p.m.