Probability and Statistics - jean-knapp/tutorials GitHub Wiki

Language: R

Sets

Creating sets

Example:

x <- c(1,2,5)
y <- c(5,1,8,9)

Operations

union(x,y)

Union of the sets x and y


intersect(x,y)

Intersection of the sets x and y


setdiff(x,y)

Set difference between x and y, consisting of all elements of x that are not in y


setequal(x,y)

Test for equality between x and y


c %in% y

Membership, testing whether c is an element of the set y


choose(n,k)

Number of possible subsets of size k chosen from a set of size n