cor0: Create tidy summary of pairwise correlations of vars in a...

View source: R/cor0.R

cor0R Documentation

Create tidy summary of pairwise correlations of vars in a dataframe

Description

Wraps typical workflow of df %>% as.matrix() %>% Hmisc::rcorr() %>% broom::tidy(). Respects grouped dataframes a la dplyr.

Usage

cor0(.data, pattern = NULL)

Arguments

.data

Dataframe.

pattern

Optional vector of patterns to match for (i.e., filter for) in the resulting two columns with variable names. Useful if only interested in correlations with a specific variable (e.g., the outcome).

Details

Drops all factors with more than 2 levels and throws a warning. Silently converts factors with 2 levels to numerics via as.numeric(x) - 1.

Examples

cor0(mtcars)

# with factors and missing data
cor0(mice::boys)

# with a filter applied
cor0(mtcars, "mpg")
cor0(mtcars, c("mpg", "cyl"))

wepelham3/sack2 documentation built on Aug. 5, 2023, 5:53 a.m.