charfun              package:relations              R Documentation

_R_e_l_a_t_i_o_n _C_h_a_r_a_c_t_e_r_i_s_t_i_c _F_u_n_c_t_i_o_n_s

_D_e_s_c_r_i_p_t_i_o_n:

     Determine the characteristic function of a relation.

_U_s_a_g_e:

     relation_charfun(x, components = FALSE)

_A_r_g_u_m_e_n_t_s:

       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
          fit the longest vector in case of binary relations.

_S_e_e _A_l_s_o:

     'relation'

_E_x_a_m_p_l_e_s:

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

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

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

