Visualization of a correlation matrix
ggcorrmat( data, cor.vars = NULL, cor.vars.names = NULL, output = "plot", matrix.type = "full", method = "square", type = "parametric", beta = 0.1, k = 2L, sig.level = 0.05, conf.level = 0.95, bf.prior = 0.707, p.adjust.method = "none", pch = 4, ggcorrplot.args = list(outline.color = "black"), package = "RColorBrewer", palette = "Dark2", colors = c("#E69F00", "white", "#009E73"), ggtheme = ggplot2::theme_bw(), ggstatsplot.layer = TRUE, ggplot.component = NULL, title = NULL, subtitle = NULL, caption = NULL, messages = TRUE, ... )
data | Dataframe from which variables specified are preferentially to be taken. |
---|---|
cor.vars | List of variables for which the correlation matrix is to be
computed and visualized. If |
cor.vars.names | Optional list of names to be used for |
output | Character that decides expected output from this function. If
|
matrix.type | Character, |
method | character, the visualization method of correlation matrix to be used. Allowed values are "square" (default), "circle". |
type | Type of association between paired samples required
(" |
beta | bending constant (Default: |
k | Number of digits after decimal point (should be an integer)
(Default: |
sig.level | Significance level (Default: |
conf.level | Scalar between 0 and 1. If unspecified, the defaults return
|
bf.prior | A number between |
p.adjust.method | What adjustment for multiple tests should be used?
( |
pch | Decides the glyphs (or point shapes) to be used for
insignificant correlation coefficients (only valid when |
ggcorrplot.args | A list of additional (mostly aesthetic) arguments that
will be passed to |
package | Name of package from which the palette is desired as string or symbol. |
palette | Name of palette as string or symbol. |
colors | A vector of 3 colors for low, mid, and high correlation values.
If set to |
ggtheme | A function, |
ggstatsplot.layer | Logical that decides whether |
ggplot.component | A |
title | The text for the plot title. |
subtitle | The text for the plot subtitle. Will work only if
|
caption | The text for the plot caption. If |
messages | Decides whether messages references, notes, and warnings are
to be displayed (Default: |
... | Currently ignored. |
Correlation matrix plot or a dataframe containing results from
pairwise correlation tests. The package internally uses
ggcorrplot::ggcorrplot
for creating the visualization matrix, while the
correlation analysis is carried out using the correlation::correlation
function.
https://indrajeetpatil.github.io/ggstatsplot/articles/web_only/ggcorrmat.html
# \donttest{ # for reproducibility set.seed(123) # if `cor.vars` not specified, all numeric variables used ggstatsplot::ggcorrmat(iris)# to get the correlalogram # note that the function will run even if the vector with variable names is # not of same length as the number of variables ggstatsplot::ggcorrmat( data = ggplot2::msleep, type = "robust", cor.vars = sleep_total:bodywt, cor.vars.names = c("total sleep", "REM sleep"), matrix.type = "lower" )#> Warning: No. of variable names doesn't equal no. of variables. #>#># to get the correlation analyses results in a dataframe ggstatsplot::ggcorrmat( data = ggplot2::msleep, cor.vars = sleep_total:bodywt, output = "dataframe" )#> # A tibble: 15 x 10 #> parameter1 parameter2 r ci_low ci_high t df p #> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <int> <dbl> #> 1 sleep_total sleep_rem 0.752 0.617 0.844 8.76 59 2.92e- 12 #> 2 sleep_total sleep_cycle -0.474 -0.706 -0.150 -2.95 30 6.17e- 3 #> 3 sleep_total awake -1.00 -1.00 -1.00 -5329. 81 2.42e-226 #> 4 sleep_total brainwt -0.360 -0.569 -0.108 -2.84 54 6.35e- 3 #> 5 sleep_total bodywt -0.312 -0.494 -0.103 -2.96 81 4.09e- 3 #> 6 sleep_rem sleep_cycle -0.338 -0.614 0.0120 -1.97 30 5.84e- 2 #> 7 sleep_rem awake -0.752 -0.844 -0.617 -8.76 59 2.91e- 12 #> 8 sleep_rem brainwt -0.221 -0.476 0.0670 -1.54 46 1.31e- 1 #> 9 sleep_rem bodywt -0.328 -0.535 -0.0826 -2.66 59 9.95e- 3 #> 10 sleep_cycle awake 0.474 0.150 0.706 2.95 30 6.17e- 3 #> 11 sleep_cycle brainwt 0.852 0.709 0.927 8.60 28 2.42e- 9 #> 12 sleep_cycle bodywt 0.418 0.0809 0.669 2.52 30 1.73e- 2 #> 13 awake brainwt 0.360 0.108 0.569 2.84 54 6.35e- 3 #> 14 awake bodywt 0.312 0.103 0.494 2.96 81 4.09e- 3 #> 15 brainwt bodywt 0.934 0.889 0.961 19.2 54 9.16e- 26 #> method nobs #> <chr> <int> #> 1 Pearson 61 #> 2 Pearson 32 #> 3 Pearson 83 #> 4 Pearson 56 #> 5 Pearson 83 #> 6 Pearson 32 #> 7 Pearson 61 #> 8 Pearson 48 #> 9 Pearson 61 #> 10 Pearson 32 #> 11 Pearson 30 #> 12 Pearson 32 #> 13 Pearson 56 #> 14 Pearson 83 #> 15 Pearson 56# }