classes: Relation Equivalence Classes

classesR Documentation

Relation Equivalence Classes

Description

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

Usage

relation_class_ids(x)
relation_classes(x)

Arguments

x

an object inheriting from class relation representing a crisp endorelation.

Value

For relation_class_ids(), 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.

For relation_classes(), an object of class relation_classes_of_objects, which is a list of sets giving the elements in the corresponding classes, named by the class ids.

Examples

## Equivalence.
f <- factor(rep(c("Good", "Bad", "Ugly"), c(3, 2, 1)))
R <- as.relation(f)
relation_is(R, "equivalence")
table(ids = relation_class_ids(R), orig = f)

relation_classes(R)

## Weak order ("weak preference").
f <- ordered(f, levels = c("Ugly", "Bad", "Good"))
R <- as.relation(f)
relation_is(R, "weak_order")
table(ids = relation_class_ids(R), orig = f)

relation_classes(R)

relations documentation built on March 7, 2023, 8:01 p.m.