Learn R Programming

prob (version 1.0-1)

intersect: Intersection of Subsets

Description

Calculates the intersection of subsets of a probability space. Comparisons are made row-wise, so that in the data frame case, intersect(A,B) is a data frame with those rows that are both in A and in B.

Usage

intersect(x, …)

# S3 method for default intersect(x, y, …)

# S3 method for data.frame intersect(x, y, …)

# S3 method for ps intersect(x, y, …)

Arguments

x, y

vectors, data frames, or ps objects containing a sequence of elements (conceptually).

further arguments to be passed to or from other methods.

Value

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

Details

This is a generic function, extended from the intersect function in the base package. The elements of intersect(x,y) are those elements in x and in y. The original definition is preserved in the case that x and y are vectors of the same mode.

See Also

union, setdiff

Examples

Run this code
# NOT RUN {
S <- cards()
A <- subset(S, suit == "Heart")
B <- subset(S, rank == "A" )
intersect(A, B)
# }

Run the code above in your browser using DataLab