Rearranges a data matrix according to a permutation order.
Usage
permute(object, order, ...)
# S4 method for class 'data.frame,PermutationOrder'
permute(object, order)
# S4 method for class 'matrix,PermutationOrder'
permute(object, order)
Arguments
- object
A \(m \times p\)
numeric
matrix
ordata.frame
of count data (absolute frequencies giving the number of individuals for each category, i.e. a contingency table).- order
A
PermutationOrder
object giving the permutation order for rows and columns.- ...
Currently not used.
See also
Other seriation methods:
as_seriation()
,
assess()
,
order()
,
refine()
,
seriate_average()
,
seriate_rank()
Examples
## Replicates Desachy 2004 results
data("compiegne", package = "folio")
## Get seriation order for columns on EPPM using the reciprocal averaging method
## Expected column order: N, A, C, K, P, L, B, E, I, M, D, G, O, J, F, H
(indices <- seriate_rank(compiegne, EPPM = TRUE, margin = 2))
#> Permutation order for matrix seriation:
#> * Row order: 1 2 3 4 5...
#> * Column order: 14 1 3 11 16 12 2 5 9 13 4 7 15 10 6 8...
## Get permutation order
order_rows(indices)
#> [1] 1 2 3 4 5
order_columns(indices)
#> [1] 14 1 3 11 16 12 2 5 9 13 4 7 15 10 6 8
## Permute columns
(new <- permute(compiegne, indices))
#> N A C K P L B E I M D G O J F H
#> 5 1510 13740 8270 1740 0 460 375 20 0 0 250 40 350 5 10 80
#> 4 565 13540 10110 7210 450 1785 1520 1230 0 410 740 265 310 105 635 400
#> 3 160 12490 4220 6750 275 5930 5255 1395 30 350 980 440 10 580 1415 680
#> 2 410 6940 5800 2130 410 2410 2880 1510 620 910 3400 1080 310 2075 2280 2840
#> 1 190 6490 6900 1080 50 570 2350 670 340 740 2745 950 985 2660 3020 6700