mbgraphic (version 1.0.1)

sdf_sort: Reordering a list of class "sdfdata"

Description

The function reorders a list of class "sdfdata" for displaying scagnostics results in scaggrams. The reordering algorithm is based on distances between "direct" neighbors. See Details.

Usage

sdf_sort(sdfdata, maxt = NULL, select = "All", printmsum = FALSE)

Arguments

sdfdata

A list of class "sdfdata".

maxt

NULL or a positive integer giving a time limit. Default is NULL (no time limit).

select

"All" or a vector of integers or strings giving the scagnostics which should be used for reordering.

printmsum

logical. Should the optimality criterion be printed after each iteration? Default is FALSE.

Value

A list of class "sdfdata".

Details

The implemented algorithm to reorder the "sdfdata" list is greedy. In each iteration all variable changes of exactly two variables are considered, that means associated rows and columns within the scaggram are switched. The (p choose 2) different orders are compared by msum. The goal is to minimize msum, which is defined as the sum of distances of all row-wise and all column-wise neighbors. The algorithm stops if no improvement is possible by changing two arbitrary variables or the specified time limit is exceeded.

See Also

sdf, scag2sdf, sdf_quicksort, scaggram, iascaggram

Examples

Run this code
# NOT RUN {
data(Election2005)
# consider only demographic/economic information
election05_ds <- Election2005[,1:40]
# }
# NOT RUN {
scagdf <- sdf(election05_ds)
# ordering based on all scagnostics from sdf
scagdf_o2 <- sdf_sort(scagdf)
# compare scaggrams
par(mfrow=c(1,2))
scaggram(scagdf,select=(c(1,5,9)))
scaggram(scagdf_o2,select=(c(1,5,9)))
# }

Run the code above in your browser using DataLab