squareform: Vectorize and reshape distance or correlation matrices.

Description Usage Arguments Value

View source: R/squareform.R

Description

When x is a distance matrix or correlation matrix (symmetric with diagonal elements equal to 0 or 1, respectively), squareform() vectorizes this matrix (i.e., "unwraps" or "flattens") into a vector (i.e., vec->mat). When x is a vector (i.e., a distance matrix or correlation matrix) squareform() reshapes this vector into the correspoding square matrix (i.e., mat->vec).

Usage

1
squareform(x, lt = TRUE, corr = FALSE, nms = NULL)

Arguments

x

square matrix or vector

lt

boolean, is only the lower-triangle (TRUE) or full matrix (all values) of interest? For lt = TRUE (default): when x is a vector, only the lower-triangle will be extracted, and when x is a vector, it will be assumed that it is a lower-triangle vector. For convenience, this can be toggled to extract/assume the full matrix (both triangles and diagonal) by setting lt = FALSE.

corr

boolean (defaults to FALSE, for distance matrices), defines the value of diagonal elements

nms

optional (applicable only when vec->mat), character vector that holds names of rows/cols of output matrix

Value

square matrix or vector


mcfreund/mfutils documentation built on Feb. 6, 2022, 4:57 a.m.