setcompare: Compare to sets

View source: R/setcompare.R

setcompareR Documentation

Compare to sets

Description

This is an wrapper around setdiff and intersect to quickly compare to sets.

Usage

setcompare(x, y)

## Default S3 method:
setcompare(x, y)

## S3 method for class 'data.frame'
setcompare(x, y)

Arguments

x, y

sets to compare. Implemented methods support atomic vectors and data frames, see Details

Details

The default method expects atomic vectors.

The method for data frames compares the sets of variable names.

Value

A list with three components

x

Elements of x not fount in y

int

Elements present in both x and y

y

Elements in y not found in x

See Also

setdiff, intersect

Examples


# default method for vectors
x <- 1:5
y <- 3:7
setcompare(x, y)
setcompare(letters[x], letters[y]) 

# method for data frames
d1 <- structure(as.data.frame(matrix(rnorm(25), 5, 5)), names=letters[x])
d2 <- structure(as.data.frame(matrix(rnorm(25), 5, 5)), names=letters[y])
setcompare(d1, d2)


mbojan/mbtools documentation built on Oct. 16, 2023, 8:18 p.m.