Learn R Programming

SensoMineR (version 1.27)

magicsort: Returns a sorted data matrix

Description

Sort the rows and columns of a matrix in a "magic" order or by ascending (or descending) mean or median or geometrical mean.

Usage

magicsort(matrice, sort.mat = matrice, method = "magic",
    byrow = TRUE, bycol = TRUE, ascending = TRUE)

Arguments

matrice

a data matrix to sort

sort.mat

sort the rows and columns according to the result of the PCA made on this matrix (by default the matrice)

method

four types of calculations, magic ("magic"), ("median"), arithmetical ("mean") or geometrical ("geo") mean (by default magic)

byrow

boolean, if TRUE then data are sorted over the rows

bycol

boolean, if TRUE then data are sorted over the columns

ascending

boolean, if TRUE then data are sorted in ascending order

Author

F Husson, S Le

Details

Very useful function to compare results.

Examples

Run this code
## Example 1
data(chocolates)
resdecat<-decat(sensochoc, formul = "~Product", firstvar = 5, 
    graph = FALSE)
coltable(magicsort(resdecat$tabT), level.lower = -1.96, 
    level.upper = 1.96, main.title = "Products' description")

## Example 2
data(chocolates)
resperf<-paneliperf(sensochoc, 
    formul = "~Product+Panelist+Product:Panelist",
    formul.j = "~Product", col.j = 1, firstvar = 5, lastvar = 12,
    synthesis = FALSE, graph = FALSE)
res.sort=magicsort(resperf$prob.ind, method = "median")
coltable(res.sort, main.title = "P-values of the F-test by panelist")

Run the code above in your browser using DataLab