Set Operations

Union: \(A \cup B = \{\xi \mid \xi \in A \text{ or } \xi \in B\}\)

Intersection \(A \cap B = \{\xi \mid \xi \in A \text{ and } \xi \in B\}\)

Complement: \(A^c = \{\xi \mid \xi \in \Omega \text{ and } \xi \notin A\} = \Omega \setminus A\)

Note the correspondence with logic: or, and, not

Difference: \(A\setminus B = \{\xi \mid \xi \in A \text{ and } \xi \notin B\} = A \cap B^c\)

A <- c(1,2,3,4,5)
B <- c(2,4,6)
union(A,B)
## [1] 1 2 3 4 5 6
intersect(A,B)
## [1] 2 4
setdiff(A,B)
## [1] 1 3 5