Skip to contents

Applies functions to a matrix or data.frame.

Usage

do_processing(x, functions = list())

Arguments

x

Matrix or Data.frame.

functions

List of lists, specifying functions to be applied as well as their arguments. See details.

Value

Matrix or data.frame with post-processing applied.

Details

Functions are passed into the post-processor as a named list. The name f of the list entry is the function to be applied via base::do.call. The list entry itself is another named list, specifying the arguments to the function f as named arguments.

The functions must take a matrix or data.frame as first argument and return another matrix or data.frame of the same dimensions as single output.

Examples of post-processing steps are truncation (process_truncate_by_iqr, process_truncate_by_threshold) or centering / standardizing data (via scale, see example section below).

Can be useful to apply on simulated datasets, even outside of the simulation function (e.g. when standardization is only required at the modeling step).

Note

Use with caution - no error checking is done for now so the user has to take care of everything themselves! Furthermore, output of the functions is not checked either.

Examples

do_processing(diag(5), 
    functions = list(scale = list(center = TRUE, scale = FALSE)))
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]  0.8 -0.2 -0.2 -0.2 -0.2
#> [2,] -0.2  0.8 -0.2 -0.2 -0.2
#> [3,] -0.2 -0.2  0.8 -0.2 -0.2
#> [4,] -0.2 -0.2 -0.2  0.8 -0.2
#> [5,] -0.2 -0.2 -0.2 -0.2  0.8
#> attr(,"scaled:center")
#> [1] 0.2 0.2 0.2 0.2 0.2