Learn R Programming

seriation (version 1.0-12)

permute: Permute a dist object, a matrix, an array, a list, or a numeric vector

Description

A method for permutingvarious classes including the observations in a dist object, the rows and columns of a matrix, and all dimensions of an array given a suitable ser_permutation object.

Usage

permute(x, order)

Arguments

x
an object (a list, a numeric vector, a dist object, a matrix, an array or any other object which provides dim and standard subsetting with "[").
order
an object of class ser_permutation which contains suitable permutation vectors for x.

Details

The permutation vectors in ser_permutation are suitable if the number of permutation vectors matches the number of dimensions of x and if the length of each permutation vector has the same length as the corresponding dimension of x.

For 1-dimensional/1-mode data (list, vector, dist), order can also be a single permutation vector of class ser_permutation_vector or data which can be automatically coerced to this class (e.g. a numeric vector).

See Also

ser_permutation, dist in package stats.

Examples

Run this code
m <- matrix(rnorm(10), 5, 2)
m

permute(m, ser_permutation(5:1, 2:1))

d <- dist(m)
d

permute(d, ser_permutation(c(3,2,1,4,5)))

## this also works for 1-mode data:
# permute(d, ser_permutation_vector(c(3,2,1,4,5)))
# permute(d, c(3,2,1,4,5))

Run the code above in your browser using DataLab