Skip to contents

Pairwise correlation matrix with p-values

Usage

correlation_matrix(data, method = "pearson")

Arguments

data

Data frame; numeric columns are used.

method

One of "pearson", "spearman", "kendall".

Value

List with components r (correlations) and p (p-values), both data.frame objects with matching dimensions.

Examples

set.seed(1)
d <- data.frame(a = rnorm(40), b = rnorm(40), c = rnorm(40))
cm <- correlation_matrix(d)
cm$r
#>            a         b          c
#> a  1.0000000 0.2294957 -0.2514938
#> b  0.2294957 1.0000000  0.1981157
#> c -0.2514938 0.1981157  1.0000000