Learn R Programming

kairos (version 2.1.1)

permute: 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 data.frame,PermutationOrder permute(object, order)

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

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

Value

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

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.

Author

N. Frerebeau

See Also

dimensio::ca()

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

Examples

Run this code
## 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
if (FALSE) {
utils::vignette("seriation")
}

Run the code above in your browser using DataLab