setcompare: Compare to sets

Description Usage Arguments Details Value See Also Examples

View source: R/setcompare.R

Description

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

Usage

1
2
3
4
5
6
7
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# 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 Nov. 9, 2017, 3:21 p.m.