order: Improving the Presentation of Matrix Objects

Description Usage Arguments Details Value Note Author(s) See Also Examples

Description

High-level functions that improve the presentation of a matrix or data frame by reordering their rows and columns.

Usage

1
2
3
4
5
order.dist(x, index = FALSE)
order.matrix(x, type = "neumann", by = c("both","rows","cols"),
             index = FALSE)
order.data.frame(x, type = "neumann", by = c("both","rows","cols"),
                 index = FALSE)

Arguments

x

an object of class dist, matrix, or data.frame.

type

the type of stress measure to use (see details).

by

option to order either by rows, or columns, or both.

index

option to return the order index(ex) instead of the reordered object.

Details

These functions try to improve the presentation of an object of class dist, matrix, or
data.frame by reordering the rows and columns such that similar entries are grouped together.

order.dist uses a simple heuristic to solve the TSP problem of finding an ordering of minimum length (see order.length) for an object of class dist. Note that the heuristic used is quick but more elaborate TSP algorithms will produce better orderings.

order.matrix tries to minimize the stress measure of a matrix (see stress by using the same TSP heuristic as above, once for the column and once for the row ordering (while the other dimension is fixed) if by = "both".

order.data.frame uses attributes of type numeric and logical only, combines them into a normalized matrix and finds an ordering as above.

Value

Either the reordered object supplied, or a vector of subscripts (for reorder.dist), or a list with components rows and columns containing the order indexes (for reorder.matrix and reorder.data.frame).

Note

This is experimental code that may be integrated in a separate packages in the future.

Author(s)

Christian Buchta

See Also

dist, stress, stress.dist.

Examples

1
2
3
4
5
6
7
## not a hard problem
data(iris)
d <- dist(iris[1:4])
implot(order.dist(d))
data(townships)
x <- order.data.frame(townships)
x

cba documentation built on May 2, 2019, 1:39 p.m.

Related to order in cba...