permute: Rearranges a Data Matrix

permuteR Documentation

Rearranges a Data Matrix

Description

  • permute() rearranges a data matrix according to a permutation order.

  • get_order() returns the seriation order for rows and/or columns.

Usage

permute(object, order, ...)

get_order(x, ...)

## S4 method for signature 'data.frame,PermutationOrder'
permute(object, order)

## S4 method for signature 'matrix,PermutationOrder'
permute(object, order)

## S4 method for signature 'PermutationOrder'
get_order(x, margin = c(1, 2))

Arguments

object

A m \times p numeric matrix or data.frame of count data (absolute frequencies giving the number of individuals for each category, i.e. a contingency table). A data.frame will be coerced to a numeric matrix via data.matrix().

...

Currently not used.

x, order

A PermutationOrder object giving the permutation order for rows and columns.

margin

A numeric vector giving the subscripts which the rearrangement will be applied over: 1 indicates rows, 2 indicates columns, c(1, 2) indicates rows and columns.

Value

  • permute() returns a permuted matrix or a permuted data.frame (the same as object).

Author(s)

N. Frerebeau

See Also

dimensio::ca()

Other seriation methods: seriate_average(), seriate_rank(), seriate_refine()

Examples

## Replicates Desachy 2004 results
data("compiegne", package = "folio")

## Get seriation order for columns on EPPM using the reciprocal averaging method
## Expected column order: N, A, C, K, P, L, B, E, I, M, D, G, O, J, F, H
(indices <- seriate_rank(compiegne, EPPM = TRUE, margin = 2))

## Get permutation order
get_order(indices, 1) # rows
get_order(indices, 2) # columns

## Permute columns
(new <- permute(compiegne, indices))

## See the vignette
## Not run: 
utils::vignette("seriation")

## End(Not run)

kairos documentation built on Nov. 27, 2023, 5:08 p.m.