Learn R Programming

relations (version 0.1-0)

charfun: Relation Characteristic Functions

Description

Determine the characteristic function of a relation.

Usage

relation_charfun(x, components = FALSE)

Arguments

x
an object inheriting from class relation.
components
a logical indicating whether the characteristic function created should take vectors (each vector corresponding to one domain) as argument, or a data frame (with the elements in the rows). In the former case, all vectors are recycled to fi

See Also

relation

Examples

Run this code
## Relation 'a divides b':
R <- relation(domain = list(1 : 10, 1 : 10),
              charfun = function(a, b) b %% a == 0)
R
## 'Recover' characteristic function:
"%D%" <- relation_charfun(R)

## Use it.
2 %D% 6
c(2, 3, 4) %D% 6
2 %D% c(2, 3, 6)

## This also works:
"%D%"(2, 6)
## (and generally does for arities > 2).

Run the code above in your browser using DataLab