focus_if | R Documentation |
Apply a predicate function to each column of correlations. Columns that
evaluate to TRUE will be included in a call to focus
.
focus_if(x, .predicate, ..., mirror = FALSE)
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. |
A tibble or, if mirror = TRUE, a correlation data frame.
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()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.