setters              package:relations              R Documentation

_M_o_d_i_f_y _R_e_l_a_t_i_o_n_s

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

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

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

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

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

       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 binary 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'. 

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

     '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.

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

     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)

