Learn R Programming

wrappedtools (version 0.9.7)

ggcormat: Print graphical representation of a correlation matrix.

Description

ggcormat makes the same correlation matrix as cortestR and graphically represents it in a plot

Usage

ggcormat(
  cor_mat,
  p_mat = NULL,
  method = "Correlation",
  title = "",
  maxpoint = 2.1,
  textsize = 5,
  axistextsize = 2,
  titlesize = 3,
  breaklabels = NULL,
  lower_only = TRUE,
  .low = "blue3",
  .high = "red2",
  .legendtitle = NULL
)

Value

A ggplot object, allowing further styling.

Arguments

cor_mat

correlation matrix as produced by cor.

p_mat

Optional matrix of p-values; if provided, this is used to define size of dots rather than absolute correlation.

method

text specifying type of correlation.

title

plot title.

maxpoint

maximum for scale_size_manual, may need adjustment depending on plotsize.

textsize

for theme text.

axistextsize

relative text size for axes.

titlesize

as you already guessed, relative text size for title.

breaklabels

currently not used, intended for str_wrap.

lower_only

should only lower triangle be plotted?

.low

Color for heatmap.

.high

Color for heatmap.

.legendtitle

Optional name for color legend.

Examples

Run this code
coeff_pvalues <- cortestR(mtcars[, c("wt", "mpg", "qsec", "hp")],
  split = TRUE, sign_symbol = FALSE
)
# focus on coefficients:
ggcormat(cor_mat = coeff_pvalues$corout, maxpoint = 5)
# size taken from p-value:
ggcormat(
  cor_mat = coeff_pvalues$corout,
  p_mat = coeff_pvalues$pout, maxpoint = 5)

Run the code above in your browser using DataLab