mat_cor_do: compute correlations among all variables

Description Usage Arguments See Also Examples

View source: R/cor_do.R

Description

compute correlations among all variables

Usage

1
mat_cor_do(df, add_stars = TRUE, digits = 2, ...)

Arguments

df

data

add_stars

Add column p_value_chr with stars?

digits

if add_stars, digits to round?

...

further arguments passed to cor.test

See Also

mat_cor_to_df

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
x1 <- rnorm(100)
x2 <- 0.2 * x1 + rnorm(100)
x3 <- 0.9 * x1 + rnorm(100, sd=0.1)
x4 <- rnorm(100)
x <- data.frame(x1, x2, x3, x4)

mat_cor_do(x)
mat_cor_do(x, add_stars = TRUE)[, c(1,2,3,4,5,11)]
mat_cor_do(x, method = "kendall")
mat_cor_do(x, method = "kendall", alternative = "greater", add_stars = TRUE)

## plot
library(ggplot2)
ggplot(aes(x = variable, y= variable2, fill = estimate), data = mat_cor_do(x)) +
   geom_tile() +
   geom_text(aes(label = estimate_pval)) +
   scale_fill_gradient2()

MatthieuStigler/matPkg documentation built on Aug. 10, 2021, 11:01 a.m.