Learn R Programming

relations (version 0.2-0)

setters: 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 Robject 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 tuple

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

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

relation_domain(R)
## tuple format:
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"))
relation_graph(R)

Run the code above in your browser using DataLab