permutation_vector2matrix: Conversion Between Permutation Vector and Permutation Matrix

View source: R/ser_permutation_vector2matrix.R

permutation_vector2matrixR Documentation

Conversion Between Permutation Vector and Permutation Matrix

Description

Converts between permutation vectors and matrices.

Usage

permutation_vector2matrix(x)

permutation_matrix2vector(x)

Arguments

x

A permutation vector (any object that can be converted into a permutation vector, e.g., a integer vector or a hclust object) or a matrix representing a permutation. Arguments are checked.

Value

  • permutation_vector2matrix(): returns a permutation matrix.

  • permutation_matrix2vector(): returns the permutation as a integer vector.

Author(s)

Michael Hahsler

See Also

Other permutation: get_order(), permute(), ser_dist(), ser_permutation(), ser_permutation_vector()

Examples

## create a random permutation vector
pv <- structure(sample(5), names = paste0("X", 1:5))
pv

## convert into a permutation matrix
pm <- permutation_vector2matrix(pv)
pm

## convert back
permutation_matrix2vector(pm)

seriation documentation built on Sept. 11, 2024, 7:33 p.m.