mat_cor_do: compute correlations among all variables

View source: R/cor_do.R

mat_cor_doR Documentation

compute correlations among all variables

Description

compute correlations among all variables

Usage

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

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 Nov. 13, 2023, 7:53 p.m.