Learn R Programming

Correlplot (version 1.1.3)

ggtally: Create a correlation tally stick on a biplot vector

Description

Function ggtally puts a series of dots along a biplot vector of a correlation matrix, so marking the change in correlation along the vector with specified values.

Usage

ggtally(p1, A, B, R, ind = 1:nrow(B), adj = 0, values = seq(-1,1,by=0.2), dotsize = 0.10,
        dotcolour = "black", dp = FALSE, linewidth = 0.1,
	W = diag(nrow(A)), xlim = c(-1, 1), ylim = c(-1, 1), verbose = FALSE,
	onedimensional = FALSE)

Value

A ggplot2 object with the updated biplot

Arguments

p1

A ggplot2 object with an existing biplot.

A

Biplot markers of the rows.

B

Biplot markers of the columns (typically the biplot vector to be calibrated).

R

The original matrix (e.g., the correlatin matrix) to be represented.

ind

The indices (row numbers in matrix B) of the biplot vector(s) to be calibrated. If not specified, all row vectors of B will be calibrated.

adj

A scalar adjustment for the correlations.

values

Values of the correlations to be marked off by dots.

dotsize

Size of the dot.

dotcolour

Colour of the dot.

dp

Drops perpendiculars (dp=TRUE) onto the biplot vector that is calibrated. Only applies to two-dimensional biplots (onedimensional=FALSE.

linewidth

The width of the biplot vector(s)

W

Weight matrix used in the calibration.

xlim

Limits for the horizontal axis. These should coincide with those used in ggbplot.

ylim

Limits for the vertical axis. These should coincide with those used in ggbplot.

verbose

Prints coordinates of tick marks if verbose=TRUE.

onedimensional

For one-dimensional biplots. This should coincide with onedimensional used in ggbplot.

Author

Jan Graffelman (jan.graffelman@upc.edu)

Details

Any set of values for the correlation to be marked off can be used, though a standard scale with 0.2 increments is recommmended.

References

Graffelman, J. and De Leeuw, J. (2023) Improved approximation and visualization of the correlation matrix. The American Statistician, 77(4), 432-442. tools:::Rd_expr_doi("10.1080/00031305.2023.2186952")

See Also

ggbplot

Examples

Run this code
library(calibrate)
data(goblets)
R <- cor(goblets)
out.sd <- eigen(R)
V  <- out.sd$vectors[,1:2]
Dl <- diag(out.sd$values[1:2])
Gp <- crossprod(t(V),sqrt(Dl))
pca.df <- data.frame(Gp)
pca.df$strings <- colnames(R)
colnames(pca.df) <- c("PA1","PA2","strings")
p1 <- ggbplot(pca.df,pca.df,main="PCA correlation biplot",xlab="",ylab="",rowarrow=TRUE,
              rowcolor="blue",rowch="",colch="")
p1 <- ggtally(p1,Gp,Gp,R,values=seq(-0.2,0.6,by=0.2),dotsize=0.1)

Run the code above in your browser using DataLab