ggcorr: Generate the ggplot for a correlation matrix

Description Usage Arguments Value Examples

View source: R/ggcorr.R

Description

Generate the ggplot for a correlation matrix

Usage

1
2
3
ggcorr(cor.mat, lower = FALSE, psize = NULL, high = "red",
  low = "blue", digits = 2, var.position = c("axis", "diagonal"),
  var.angle = 30, add.legend = TRUE)

Arguments

cor.mat

A correlation matrix, usually generated with cor() function

lower

Whether to plot the lower triangle only

psize

The poit size for the dots

high

The color represents the high (positive) correlation

low

The color represents the low (negative) correlation

digits

The number of digits shown for the correlation values

var.position

The position to put the variable names. If the value is "axis", the variable names will be at the x and y axis. If the value is "diagonal", the variable names will be put along the diagonal line.

var.angle

The angle of the text for the variable names on the X axis or The diagonal line.

add.legend

Whether to add the legend for color (TRUE/FALSE)

Value

A ggplot of the correlation matrix

Examples

1
2
3
4
5
6
7
8
xx <- matrix(runif(100), 10)
colnames(xx) <- paste0('Variable ', 1:ncol(xx))
cor.mat <- cor(xx)

ggcorr(cor.mat)  # default plot
ggcorr(cor.mat, var.position = 'diagonal', high = 'blue', low = 'green',
  add.legend = FALSE)
ggcorr(cor.mat, lower = TRUE, var.position = 'diagonal')

JianhuaHuang/streamit documentation built on Aug. 19, 2018, 6:59 a.m.