Plot a Correlation Matrix

Share:

Description

Plot a correlation matrix with scatterplots, correlation coefficients and colors.

Usage

1
2
3
plotCor(tab,
        method = c("pearson", "kendall", "spearman"),
        formatCor, colCor, ...)

Arguments

tab

a dataframe. Contain the variable whose correlation is of interest.

method

among pearson, kendall and spearman. Method used to compute the correlation coefficient.

formatCor

a function. Applied to a htest object and returning a character string, formats the display of the correlation coefficient.

colCor

a function. Applied to a htest object and returning a color (character string or rgb).

...

additional arguments passed to formatCor.

Details

Displays a matrix plot where the diagonal contains the variable names, the lower triangle displays scatterplots between the variables and the upper triangle correlation coefficients with colors corresponding the the magnitude of the correlation.

Value

Nothing of interest.

Author(s)

Antoine Filipovic Pierucci

See Also

cor.test.

Examples

1
2
3
4
5
x <- iris[, 1:4]
plotCor(x)

plotCor(x, formatCor = function(x) round(x$estimate, 2))
plotCor(x, colCor = function(x) if (x$estimate > 0) "green" else "yellow")