## 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)
Run the code above in your browser using DataLab