Learn R Programming

prob (version 0.9-1)

setdiff: Set Difference of Subsets

Description

Calculates the (nonsymmetric) set difference of subsets of a probability space.

Usage

setdiff(x, ...)

## S3 method for class 'default':
setdiff(x, y, \ldots)

## S3 method for class 'data.frame':
setdiff(x, y, \ldots)

## S3 method for class 'ps':
setdiff(x, y, \ldots)

Arguments

x, y
vectors, data frames, or ps objects containing a sequence of items (conceptually).
...
further arguments to be passed to or from other methods.

Value

  • A data frame or subset of a probability space of the same type as its arguments.

Details

This function operates row-wise on dataframes, and element-wise among the outcomes of ps objects. The elements of setdiff(x,y) are those elements in x but not in y. The definition is taken to match the version in the base package.

See Also

intersect, union

Examples

Run this code
S <- cards()
A <- subset(S, suit == "Heart")
B <- subset(S, rank == "A" )
setdiff(B, A)

Run the code above in your browser using DataLab