plotcor: Plot a Matrix of Correlations

Description Usage Arguments Details Value See Also Examples

View source: R/plotcor.R

Description

Plot a matrix of correlations using white ellipses (representing the measured correlation) overlaid on colored circles.

Usage

1
2
3
4
5
6
7
8
9
plotcor(
  r,
  addtext = TRUE,
  atcex = NULL,
  incdiag = FALSE,
  rorder = TRUE,
  plot = TRUE,
  ...
)

Arguments

r

A matrix of correlations (need not be symmetrical) with values ranging from -1 to 1.

addtext

A logical scalar indicating whether the value of each correlation should be written over the ellipses, default TRUE.

atcex

A numeric scalar giving the magnification of the added ellipse text relative to that set in par, default NULL results in atcex=8/maximum dimension of r.

incdiag

A logical scalar indicating whether to plot circles for the diagonal values of the matrix (if symmetric), default FALSE.

rorder

A logical scalar indicating whether the columns and rows of the matrix should be reordered using seriation, default TRUE.

plot

A logical scalar indicating whether the plot should be drawn, default TRUE.

...

Additional parameters to par.

Details

Correlation is represented as a white ellipse over a colored circle, sized so that the proportion of the colored circle visible beyond the ellipse is equal to the squared correlation (r^2). The color of each circle ranges from cyan (for r = -1) to magenta (for r = 1) through white (for r = 0). Similarly, the transparency of each printed correlation value (if addtext=TRUE) ranges from 1 (for r = 0) to 0 (for |r| = 1).

Value

A list of with two vector of integers (the same length as each dimension of r) representing the linear order suggested by seriation.

See Also

plotcorr on which the idea for the function was based, seriate, and draw.ellipse.

Examples

1
2
3
4
5
6
7
8
# example using a symmetric matrix
sr <- cor(swiss)
sord <- plotcor(sr)
sr[sord[[1]], sord[[2]]]
# example using an asymmetric matrix
lr <- cor(longley)[1:3, 4:7]
lord <- plotcor(lr)
lr[lord[[1]], lord[[2]]]

JVAdams/jvamisc documentation built on Aug. 11, 2021, 6:43 a.m.