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.
ggcorrmat( data, cor.vars = NULL, cor.vars.names = NULL, output = "plot", matrix.type = "upper", type = "parametric", beta = 0.1, partial = FALSE, k = 2L, sig.level = 0.05, conf.level = 0.95, bf.prior = 0.707, p.adjust.method = "holm", pch = "cross", ggcorrplot.args = list(method = "square", 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, ... )
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, |
type | Type of association between paired samples required
(" |
beta | bending constant (Default: |
partial | Can be |
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 | Adjustment method for p-values for multiple
comparisons. Possible methods are: |
pch | Decides the point shape 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 the package from which the given palette is to
be extracted. The available palettes and packages can be checked by running
|
palette | Name of the package from which the given palette is to
be extracted. The available palettes and packages can be checked by running
|
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. |
... | Currently ignored. |
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" )#># to get the correlation analyses results in a dataframe ggstatsplot::ggcorrmat( data = ggplot2::msleep, cor.vars = sleep_total:bodywt, partial = TRUE, output = "dataframe" )#> # A tibble: 15 x 10 #> parameter1 parameter2 estimate conf.low conf.high statistic df #> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <int> #> 1 sleep_total sleep_rem 0.314 -0.0520 0.606 1.75 28 #> 2 sleep_total sleep_cycle -0.0225 -0.380 0.341 -0.119 28 #> 3 sleep_total awake -1 -1 -1 -Inf 28 #> 4 sleep_total brainwt -0.0970 -0.442 0.273 -0.516 28 #> 5 sleep_total bodywt -0.179 -0.506 0.194 -0.961 28 #> 6 sleep_rem sleep_cycle -0.0766 -0.425 0.292 -0.407 28 #> 7 sleep_rem awake 0.0560 -0.311 0.408 0.297 28 #> 8 sleep_rem brainwt 0.0857 -0.283 0.433 0.455 28 #> 9 sleep_rem bodywt -0.0341 -0.390 0.330 -0.181 28 #> 10 sleep_cycle awake -0.00479 -0.364 0.356 -0.0253 28 #> 11 sleep_cycle brainwt 0.801 0.620 0.901 7.08 28 #> 12 sleep_cycle bodywt -0.0949 -0.440 0.275 -0.505 28 #> 13 awake brainwt -0.0957 -0.441 0.274 -0.509 28 #> 14 awake bodywt -0.448 -0.696 -0.104 -2.65 28 #> 15 brainwt bodywt 0.252 -0.119 0.561 1.38 28 #> p.value method n.obs #> <dbl> <chr> <int> #> 1 1 Pearson 30 #> 2 1 Pearson 30 #> 3 0 Pearson 30 #> 4 1 Pearson 30 #> 5 1 Pearson 30 #> 6 1 Pearson 30 #> 7 1 Pearson 30 #> 8 1 Pearson 30 #> 9 1 Pearson 30 #> 10 1 Pearson 30 #> 11 0.00000148 Pearson 30 #> 12 1 Pearson 30 #> 13 1 Pearson 30 #> 14 0.170 Pearson 30 #> 15 1 Pearson 30# }