focus_if {corrr} | R 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
|
.predicate |
A predicate function to be applied to the columns. The
columns for which .predicate returns TRUE will be included as variables in
|
... |
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()
[Package corrr version 0.4.4 Index]