Stats

168 Contributors: 3 Monday, August 15, 2016
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap

Set operations

Remarks

A set contains only one copy of each distinct element. Unlike some other programming languages, base R does not have a dedicated data type for sets. Instead, R treats a vector like a set by taking only its distinct elements. This applies to the set operators, setdiff, intersect, union, setequal and %in%. For v %in% S, only S is treated as a set, however, not the vector v.

For a true set data type in R, the Rcpp package provides some options.

Related Examples