ggcorr {GGally}R Documentation

ggcorr - Plot a correlation matrix with ggplot2

Description

Function for making a correlation plot starting from a data matrix, using ggplot2. The function is directly inspired by Tian Zheng and Yu-Sung Su's arm::corrplot function. Please visit http://github.com/briatte/ggcorr for the latest development and descriptions about ggcorr.

Usage

ggcorr(data, method = "pairwise", palette = "RdYlGn", name = "rho",
  geom = "tile", max_size = 6, label = FALSE, label_alpha = FALSE,
  label_color = "black", label_round = 1, ...)

Arguments

data

a data matrix. Should contain numerical (continuous) data.

method

a character string giving a method for computing covariances in the presence of missing values. This must be (an abbreviation of) one of the strings "everything", "all.obs", "complete.obs", "na.or.complete", or "pairwise.complete.obs". Defaults to "pairwise".

palette

a ColorBrewer palette to be used for correlation coefficients. Defaults to "RdYlGn".

name

a character string for the legend that shows quintiles of correlation coefficients.

geom

the geom object to use. Accepts either tile (the default) or circle, to plot proportionally scaled circles.

max_size

the maximum size for circles, as passed to scale_size_area for proportional scaling. Defaults to 6.

label

whether to add correlation coefficients as two-digit numbers over the plot. Defaults to FALSE.

label_alpha

whether to make the correlation coefficients transparent as they come close to 0. Defaults to FALSE.

label_color

color for the correlation coefficients. Defaults to "black".

label_round

decimal rounding of the correlation coefficients. Defaults to 1.

...

other arguments supplied to geom_text for the diagonal labels. Arguments pertaining to the title or other items can be achieved through ggplot2 methods.

Author(s)

Francois Briatte f.briatte@gmail.com

See Also

cor and corrplot

Examples

# Basketball statistics provided by Nathan Yau at Flowing Data.
nba <- read.csv("http://datasets.flowingdata.com/ppg2008.csv")
# Default output.
ggcorr(nba[, -1])
# Labelled output, with coefficient transparency.
ggcorr(nba[, -1],
       label = TRUE,
       label_alpha = TRUE,
       name = "") +
  ggplot2::theme(legend.position = "bottom")
# Custom options.
ggcorr(
  nba[, -1],
  geom = "circle",
  max_size = 6,
  size = 3,
  hjust = 0.75,
  angle = -45,
  palette = "PuOr" # colorblind safe, photocopy-able
) + ggplot2::labs(title = "Points Per Game")

[Package GGally version 0.5.0 Index]