permute

0th

Percentile

Permute the Order in Various Objects

Provides the generic function and methods for permuting the order of various objects including vectors, dendrograms (also hclust objects), the order of observations in a dist object, the rows and columns of a matrix, all dimensions of an array given a suitable ser_permutation object.

Keywords
manip
Usage
permute(x, order, ...)
Arguments
x
an object (a list, a 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.
...
additional arguments for the permutation function.
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).

For dendrograms and hclust, subtrees are rotated to represent the order best possible. If the order is not achived perfectly then the user is warned. This behavior can be changed with the extra parameter incompatible which can take the values "warn" (default), "stop" or "ignore".

See Also

ser_permutation, dist in package stats.

Aliases
  • permute
  • permute.dist
  • permute.numeric
  • permute.list
  • permute.matrix
  • permute.array
  • permute.data.frame
  • permute.hclust
  • permute.dendrogram
Examples
## permute matrix
m <- matrix(rnorm(10), 5, 2, dimnames = list(1:5, 1:2))
m

## permute rows and columns
permute(m, ser_permutation(5:1, 2:1))
## permute only columns
permute(m, ser_permutation(NA, 2:1))
  
## permute objects in a dist object
d <- dist(m)
d

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

## permute a list
l <- list(a=1:5, b=letters[1:3], c=0)
l
  
permute(l, c(2,3,1))    

## permute a dendrogram
hc <- hclust(d)
plot(hc)
plot(permute(hc, 5:1))
Documentation reproduced from package seriation, version 1.2-2, License: GPL-3

Community examples

Looks like there are no examples yet.