Learn R Programming

rmngb (version 0.6-1)

plotCor: Plot a Correlation Matrix

Description

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

Usage

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.

Value

Nothing of interest.

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.

See Also

cor.test.

Examples

Run this code
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")

Run the code above in your browser using DataLab