corPlot: Correlation plots

View source: R/correlation_plots.R

corPlotR Documentation

Correlation plots

Description

Produces a scatter plot with the distribution of points according to the tested variables in the lower left triangle and the correlation values in the upper left triangle.

Usage

corPlot(df, method = "spearman", digits = 2, na.action = "keep", ties.method = "average",
        title = "", xlab = "variable.name", ylab = "variable.name", ...)

Arguments

df

a matrix or a data.frame. The values of variables (e.g., indices) to be compared are in columns.

method

pearson, spearman or kendall. This is the method to be used to produce the plot, according to cor.test. See details.

digits

Number of digits to round the correlation values on the plot.

na.action

for controlling the treatment of NAs in spearman or kendall plots. If TRUE, missing values in the data are put last; if FALSE, they are put first; if NA, they are removed; if "keep" they are kept with rank NA. See rank.

ties.method

average, first, random, max, or min; a character string specifying how ties are treated in spearman or kendall plots. See rank for details.

title

Title of the plot.

xlab

a character string for labelling x axes. variable.name (default value) will produce automatic labelling according to column names of df. Otherwise, either a single string can be entered, or a vector of strings of length equal to the number of columns of df.

ylab

a character string for labelling y axes. variable.name (default value) will produce automatic labelling according to column names of df. Otherwise, either a single string can be entered, or a vector of strings of length equal to the number of columns of df.

...

Further arguments to be passed to the individual plots. See plot and par

Details

The lower half shows the scatter plots of values or ranks of variables. The upper half shows the corresponding correlation coefficients (significativity: 0 '***' 0.001 '**' 0.01 '*' 0.05 '-' 0.1 ' ' 1). The diagonal shows the considered variables and the number of individuals available for each.

If the chosen method is pearson, then the actual values of the variables will be plotted. If the chosen method is a rank-based method, spearman or kendall, then the ranks will be plotted.

Warning

A high number of variables will likely result in a slow generation of plots and a poor readability. Above 10 variables, the readability is greatly reduced.

Author(s)

Boris Leroy leroy.boris@gmail.com

See Also

corrplot in package arm

Examples

# Comparisons of species occurrences estimated from 2 different scales
data(spid.occ)
corPlot(spid.occ, method = "pearson")

# Another example:
# Correlation between different variables measured on the same individuals
data(iris)
corPlot(iris[, 1:4], method = "pearson")
corPlot(iris[, 1:4], method = "spearman")

Farewe/Rarity documentation built on Aug. 28, 2023, 2:47 a.m.