corPrint: Print a Correlation Matrix with Special Formatting

View source: R/corPrint.R

corPrintR Documentation

Print a Correlation Matrix with Special Formatting

Description

Display a correlation matrix in readable, compact form.

Usage

corPrint(R, min_value=0)

Arguments

R

Square, input correlation matrix.

min_value

The minimal value in magnitude of the displayed correlations.

Details

Drop the 0. characters of each displayed correlation coefficient. For example, display 0.42 as 42. Have an option to only display correlations larger in magnitude than a minimum threshold, so that all correlations between -min_value and +min_value display as blank spaces.

Value

The output correlation matrix.

Author(s)

David W. Gerbing (Portland State University; gerbing@pdx.edu)

See Also

Correlation, corReorder.

Examples

mycor <- matrix(nrow=6, ncol=6, byrow=TRUE,
c(1.000,0.480,0.320,0.192,0.144,0.096,
  0.480,1.000,0.240,0.144,0.108,0.072,
  0.320,0.240,1.000,0.096,0.072,0.048,
  0.192,0.144,0.096,1.000,0.480,0.320,
  0.144,0.108,0.072,0.480,1.000,0.240,
  0.096,0.072,0.048,0.320,0.240,1.000))
colnames(mycor) <- c("X1", "X2", "X3", "X4", "X5", "X6")
rownames(mycor) <- colnames(mycor)

# display all the correlations
corPrint(mycor)

# only display correlations in magnitude of 0.2 or larger
corPrint(mycor, min_value=.2)

lessR documentation built on June 8, 2025, 10:35 a.m.