Learn R Programming

GSNA (version 0.1.4.2)

distMat2Rank: distMat2Rank

Description

Convert a symmetrical numerical matrix of distances to a matrix of ranks. Note: Only the lower side of the matrix is used. Data on the upper right are assumed to be redundant.

Usage

distMat2Rank(mat, lower_is_closer = TRUE)

Value

A symmetric matrix of scaled ranks (quantiles). The matrix has the attribute 'lower_is_closer' set to 'TRUE'.

Arguments

mat

A numerical matrix containing distances.

lower_is_closer

Logical indicating that lower is closer.

Details

This is used by default by gsnPareNetGenericHierarchic.

See Also

distMat2UnitNormRank()

Examples

Run this code

# Start with a matrix of distances:
mat.dist <-  matrix( c( NA, -400, -600, NA, NA, -120, NA, NA, NA ), nrow = 3, ncol = 3 )
# Get the ranks as a matrix:
mat.ranks <- distMat2Rank(mat.dist)

# If, for this given metric, higher numbers are closer
# or more similar, do this instead:
mat.ranks2 <- distMat2Rank(mat.dist, lower_is_closer = FALSE)

Run the code above in your browser using DataLab