Plot correlation matrix as ellipses or tiles.

sjp.corr(data, title = NULL, axis.labels = NULL, sort.corr = TRUE,
decimals = 3, na.deletion = c("listwise", "pairwise"),
corr.method = c("pearson", "spearman", "kendall"), geom.colors = "RdBu",
wrap.title = 50, wrap.labels = 20, show.legend = FALSE,
legend.title = NULL, show.values = TRUE, show.p = TRUE,
p.numeric = FALSE, prnt.plot = TRUE)

## Arguments

data Matrix with correlation coefficients as returned by the cor-function, or a data.frame of variables where correlations between columns should be computed. character vector, used as plot title. Depending on plot type and function, will be set automatically. If title = "", no title is printed. For effect-plots, may also be a character vector of length > 1, to define titles for each sub-plot or facet. character vector with labels used as axis labels. Optional argument, since in most cases, axis labels are set automatically. Logical, if TRUE (default), the axis labels are sorted according to the correlation strength. If FALSE, axis labels appear in order of how variables were included in the cor-computation or data frame. Indicates how many decimal values after comma are printed when the values labels are shown. Default is 3. Only applies when show.values = TRUE. Indicates how missing values are treated. May be either "listwise" (default) or "pairwise". May be abbreviated. Indicates the correlation computation method. May be one of "spearman" (default), "pearson" or "kendall". May be abbreviated. user defined color for geoms. See 'Details' in sjp.grpfrq. numeric, determines how many chars of the plot title are displayed in one line and when a line break is inserted. numeric, determines how many chars of the value, variable or axis labels are displayed in one line and when a line break is inserted. logical, if TRUE, and depending on plot type and function, a legend is added to the plot. character vector, used as title for the plot legend. Logical, whether values should be plotted or not. Logical, adds significance levels to values, or value and variable labels. Logical, if TRUE, the p-values are printed as numbers. If FALSE (default), asterisks are used. logical, if TRUE (default), plots the results as graph. Use FALSE if you don't want to plot any graphs. In either case, the ggplot-object will be returned as value.

## Value

(Insisibily) returns the ggplot-object with the complete plot (plot) as well as the data frame that was used for setting up the ggplot-object (df) and the original correlation matrix (corr.matrix).

## Details

Required argument is either a data.frame or a matrix with correlation coefficients as returned by the cor-function. In case of ellipses, the ellipses size indicates the strength of the correlation. Furthermore, blue and red colors indicate positive or negative correlations, where stronger correlations are darker.

## Note

If data is a matrix with correlation coefficients as returned by the cor-function, p-values can't be computed. Thus, show.p and p.numeric only have an effect if data is a data.frame.

## See also

sjt.corr

## Examples

# create data frame with 5 random variables
mydf <- data.frame(cbind(runif(10), runif(10), runif(10),
runif(10), runif(10)))

# plot correlation matrix
sjp.corr(mydf)#> Computing correlation using pearson-method with listwise-deletion...
# -------------------------------
# Data from the EUROFAMCARE sample dataset
# -------------------------------
library(sjlabelled)
data(efc)

# retrieve variable and value labels
varlabs <- get_label(efc)

# create data frame
vars.index <- c(1, 4, 15, 19, 20, 21, 22, 24, 25)
mydf <- data.frame(efc[, vars.index])
colnames(mydf) <- varlabs[vars.index]

# show legend
sjp.corr(mydf, show.legend = TRUE)#> Computing correlation using pearson-method with listwise-deletion...
# -------------------------------
# auto-detection of labels
# -------------------------------
sjp.corr(efc[, vars.index])#> Computing correlation using pearson-method with listwise-deletion...