Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

ggally_cor

Correlation value plot


Description

Estimate correlation from the given data. If a color variable is supplied, the correlation will also be calculated per group.

Usage

ggally_cor(
  data,
  mapping,
  ...,
  stars = TRUE,
  method = "pearson",
  use = "complete.obs",
  display_grid = FALSE,
  digits = 3,
  title_args = list(...),
  group_args = list(...),
  justify_labels = "right",
  align_percent = 0.5,
  title = "Corr",
  alignPercent = warning("deprecated. Use `align_percent`"),
  displayGrid = warning("deprecated. Use `display_grid`")
)

Arguments

data

data set using

mapping

aesthetics being used

...

other arguments being supplied to geom_text() for the title and groups

stars

logical value which determines if the significance stars should be displayed. Given the cor.test p-values, display

"***"

if the p-value is < 0.001

"**"

if the p-value is < 0.01

"*"

if the p-value is < 0.05

"."

if the p-value is < 0.10

""

otherwise

method

method supplied to cor function

use

use supplied to cor function

display_grid

if TRUE, display aligned panel grid lines. If FALSE (default), display a thin panel border.

digits

number of digits to be displayed after the decimal point. See formatC for how numbers are calculated.

title_args

arguments being supplied to the title's geom_text()

group_args

arguments being supplied to the split-by-color group's geom_text()

justify_labels

justify argument supplied when formatting the labels

align_percent

relative align position of the text. When justify_labels = 0.5, this should not be needed to be set.

title

title text to be displayed

alignPercent, displayGrid

deprecated. Please use their snake-case counterparts.

Author(s)

Barret Schloerke

See Also

Examples

# Small function to display plots only if it's interactive
p_ <- GGally::print_if_interactive

data(tips, package = "reshape")
p_(ggally_cor(tips, mapping = ggplot2::aes_string(x = "total_bill", y = "tip")))
# display with grid
p_(ggally_cor(
  tips,
  mapping = ggplot2::aes_string(x = "total_bill", y = "tip"),
  display_grid = TRUE
))
# change text attributes
p_(ggally_cor(
  tips,
  mapping = ggplot2::aes(x = total_bill, y = tip),
  size = 15,
  colour = I("red"),
  title = "Correlation"
))
# split by a variable
p_(ggally_cor(
  tips,
  mapping = ggplot2::aes_string(x = "total_bill", y = "tip", color = "sex"),
  size = 5
))

GGally

Extension to 'ggplot2'

v2.1.1
GPL (>= 2.0)
Authors
Barret Schloerke [aut, cre], Di Cook [aut, ths], Joseph Larmarange [aut], Francois Briatte [aut], Moritz Marbach [aut], Edwin Thoen [aut], Amos Elberg [aut], Ott Toomet [ctb], Jason Crowley [aut], Heike Hofmann [ths], Hadley Wickham [ths]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.