setters: Modify Relations

settersR Documentation

Modify Relations

Description

Modify relations by (re)setting their domain, graph, or incidences.

Usage

relation_domain(x) <- value
relation_domain_names(x) <- value
relation_graph(x) <- value
relation_incidence(x) <- value

Arguments

x

an R object inheriting from class relation.

value

for setting the domain, a tuple (or list) as long as the arity of the relation x, with sets of cardinality (for lists: numbers of elements) identical to the size of x.

For setting the graph, either a set of tuples of equal lengths (arity of the relation) or a data frame or something coercible to this, with the values of the components of the given tuples (rows) always elements of the corresponding elements of the domain of x.

For setting incidences, a numeric array with values in the unit interval or a logical array, with dimension the size of the relation x.

For setting the domain names, a character vector as long as the arity of the relation x.

See Also

relation_domain() for getting the domain of a relation; relation_domain_names() for getting the domain names; relation_graph() for getting the graph; relation_incidence() for getting the incidences; relation() for basic information.

Examples

R <- as.relation(1 : 3)
print(R)

relation_domain(R)
## tuple format:
require("sets")				# set(), pair() etc.
relation_domain(R) <- pair(X = set("a","b","c"), Y = set("A","B","C"))
relation_domain(R)
## the same in list format:
relation_domain(R) <- list(X = letters[1:3], Y = LETTERS[1:3])
relation_domain(R)

relation_domain_names(R) <- c("XX","YY")
relation_domain_names(R)

relation_incidence(R)
relation_incidence(R) <- diag(1, 3, 3)
relation_incidence(R)

relation_graph(R)
## set format:
relation_graph(R) <- set(pair("a","B"), pair("a","C"), pair("b","C"))
relation_graph(R)
## the same in data frame format:
relation_graph(R) <-
    data.frame(c("a", "a", "b"), c("B", "C", "C"),
               stringsAsFactors = FALSE)
relation_graph(R)


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