View source: R/ser_permutation_vector2matrix.R
permutation_vector2matrix | R Documentation |
Converts between permutation vectors and matrices.
permutation_vector2matrix(x)
permutation_matrix2vector(x)
x |
A permutation vector (any object that can be converted into a
permutation vector, e.g., a integer vector or a |
permutation_vector2matrix()
: returns a permutation matrix.
permutation_matrix2vector()
: returns the permutation as a integer vector.
Michael Hahsler
Other permutation:
get_order()
,
permute()
,
ser_dist()
,
ser_permutation()
,
ser_permutation_vector()
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.