Sets

TODO

  • link to combinatorics

Install required packages

DescTools, sets

Treating duplicate values

[1] TRUE
[1] FALSE  TRUE  TRUE FALSE  TRUE FALSE  TRUE
[1] 1 3 4
[1] 3

AllDuplicated() from package DescTools indicates all occurrences of a duplicated value, even the first one.

[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE

Set operations

Union

[1] 2 1 3 5 4

Intersection

[1] 1 3

Asymmetric and symmetric difference

[1] 2
[1] 5 4
[1] 2 5 4

Is \(e\) an element of set \(X\)?

[1] FALSE  TRUE  TRUE FALSE  TRUE FALSE
[1]  TRUE FALSE  TRUE

(Proper) subset

[1] TRUE
[1] FALSE
[1] TRUE

Set operations using package sets

[1] FALSE
[1] 2
{{}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}
{(4, 1), (4, 2), (5, 1), (5, 2), (6, 1), (6, 2)}
[1] TRUE
{1, 2, 3, 4, 5}
{1, 3}
{1, 2, 3, 7, 8, 9, 10}
{4, 5}
[1] TRUE
[1] TRUE
[1] TRUE

Detach (automatically) loaded packages (if possible)

Get the article source from GitHub

R markdown - markdown - R code - all posts