R: Canonicalize set and mapping

canonicalize set and mapping {sets} | R Documentation

## Canonicalize set and mapping

### Description

Helper function that canonicalizes set elements, and possibly reorders a given mapping accordingly.

### Usage

    canonicalize_set_and_mapping(x, mapping = NULL, margin = NULL)

### Arguments

`x` | An object to be transformed into a set.
`mapping` | A list, array or data frame representing a mapping of the set.
`margin` | Margins to be reordered (ignored if `mapping` is a list). If `NULL`, all margins with the same length of `x` will be used.

### Details

This helper function can be used when a set is to be created from some object `x`, and another object contains some meta-information on the set elements in the same order than the elements of `x`. The set creation can cause the input elements to be permuted. By the use of this function, the meta information can be kept in sync with the result of iterating over the associated set.

### Value

A list with three named components:

`set` | The set created from `x`.
`mapping` | `mapping`, possibly reordered to match the order of `set`.
`order` | The order used for rearranging the mapping.

### See Also

`set`.

### Examples

    L <- list(c, "a", 3)
    M1 <- list("a","b","c")
    M2 <- matrix(1:9, ncol = 3)
    canonicalize_set_and_mapping(L, M1)
    canonicalize_set_and_mapping(L, M2)
    canonicalize_set_and_mapping(L, M2, 1)

[Package sets version 1.0-18 Index]