## create a random ser_permutation_vector
## Note that ser_permutation_vector is a single permutation vector
x <- structure(1:10, names = paste0("X", 1:10))
o <- sample(x)
o
p <- ser_permutation_vector(o)
p
get_order(p)
get_rank(p)
get_permutation_matrix(p)
## reorder objects using subsetting, the provided permute function or by
## multiplying the with the permutation matrix. We use here
x[get_order(p)]
permute(x, p)
drop(get_permutation_matrix(p) %*% x)
## ser_permutation contains one permutation vector for each dimension
p2 <- ser_permutation(p, sample(5))
p2
get_order(p2, dim = 2)
get_rank(p2, dim = 2)
get_permutation_matrix(p2, dim = 2)
Run the code above in your browser using DataLab