focus_if: Conditionally focus correlation data frame

View source: R/reshape.R

focus_ifR Documentation

Conditionally focus correlation data frame

Description

Apply a predicate function to each column of correlations. Columns that evaluate to TRUE will be included in a call to focus.

Usage

focus_if(x, .predicate, ..., mirror = FALSE)

Arguments

x

Correlation data frame or object to be coerced to one via as_cordf.

.predicate

A predicate function to be applied to the columns. The columns for which .predicate returns TRUE will be included as variables in focus.

...

Additional arguments to pass to the predicate function if not anonymous.

mirror

Boolean. Whether to mirror the selected columns in the rows or not.

Value

A tibble or, if mirror = TRUE, a correlation data frame.

Examples

library(dplyr)
any_greater_than <- function(x, val) {
  mean(abs(x), na.rm = TRUE) > val
}

x <- correlate(mtcars)

x %>% focus_if(any_greater_than, .6)
x %>% focus_if(any_greater_than, .6, mirror = TRUE) %>% network_plot()

corrr documentation built on Aug. 17, 2022, 1:05 a.m.