Metrics are functions that tell how much information would be lost for a given reduction in the data. reduce. as_measure() is a helper function to create new metrics to be used in partitioners. partitioners can be created with as_partitioner().

as_measure(.f, ...)

Arguments

.f

a function that returns either a numeric vector or a data.frame

...

Extra arguments passed to .f.

Value

a function to use in as_partitioner()

Examples


inter_item_reliability <- function(mat) {
  corrs <- corr(mat)
  corrs[lower.tri(corrs, diag = TRUE)] <- NA

  corrs %>%
    colMeans(na.rm = TRUE) %>%
    mean(na.rm = TRUE)
}

measure_iir <- as_measure(inter_item_reliability)
measure_iir
#> function (.partition_step, ...) 
#> {
#>     if (.partition_step$all_done) {
#>         return(.partition_step)
#>     }
#>     composite_variables <- pull_composite_variables(.partition_step)
#>     target_data <- .partition_step$.df[, composite_variables, 
#>         drop = FALSE]
#>     .partition_step$metric <- .f(target_data, ...)
#>     .partition_step
#> }
#> <bytecode: 0x555a64b11fd0>
#> <environment: 0x555a64b11278>