Reducers are functions that tell the partition algorithm how to reduce the data. as_reducer() is a helper function to create new reducers to be used in partitioners. partitioners can be created with as_partitioner().

as_reducer(.f, ..., returns_vector = TRUE, first_match = NULL)

Arguments

.f

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

...

Extra arguments passed to .f.

returns_vector

logical. Does .f return a vector? TRUE by default. If FALSE, assumes that .f returns a data.frame.

first_match

logical. Should the partition algorithm stop when it finds a reduction that is equal to the threshold? Default is TRUE for reducers that return a data.frame and FALSE for reducers that return a vector

Value

a function to use in as_partitioner()

Examples


reduce_row_means <- as_reducer(rowMeans)
reduce_row_means
#> function (.partition_step, ...) 
#> {
#>     mapping_f(.partition_step, .f, ...)
#> }
#> <bytecode: 0x55c96cfebb00>
#> <environment: 0x55c96cfeb6a0>