Learn R Programming

relations (version 0.1-0)

classes: Relation Equivalence Classes

Description

Provide class ids for an equivalence relation, or the indifference relation of a weak order.

Usage

relation_class_ids(x)

Arguments

x
an object inheriting from class relation.

Value

  • A numeric vector with class ids corresponding to the classes of the equivalence relation, or the indifference relation of the weak order with ids ordered according to increasing preference.

Examples

Run this code
## Equivalence.
f <- factor(rep(c("Good", "Bad", "Ugly"), c(3, 2, 1)))
R <- as.relation(f)
relation_is_equivalence(R)
table(ids = relation_class_ids(R), orig = f)
## Weak order ("weak preference").
f <- as.ordered(f)
R <- as.relation(f)
relation_is_weak_order(R)
table(ids = relation_class_ids(R), orig = f)

Run the code above in your browser using DataLab