Convenience function to create a function to be used as parameter fun.scaling when you want to use your own precomputed center and scale.

as_scaling_fun(center.col, scale.col, ind.col = seq_along(center.col))

Arguments

center.col

Vector of centers corresponding to ind.col.

scale.col

Vector of scales corresponding to ind.col.

ind.col

Column indices for which these are provided.

Value

A function to be used as parameter fun.scaling.

Examples

fun.scaling <- as_scaling_fun(1:6, 2:7)
fun.scaling(NULL, NULL, 1:3)  # first two parameters X and ind.row are not used here
#>   center scale
#> 1      1     2
#> 2      2     3
#> 3      3     4
fun.scaling2 <- as_scaling_fun(1:6, 2:7, ind.col = 6:1)
fun.scaling2(NULL, NULL, 1:3)
#>   center scale
#> 6      6     7
#> 5      5     6
#> 4      4     5


X <- big_attachExtdata()
sc <- big_scale()(X)
fun <- as_scaling_fun(center = sc$center, scale = sc$scale)
obj.svd <- big_randomSVD(X, fun.scaling = fun)
obj.svd2 <- big_randomSVD(X, fun.scaling = big_scale())
all.equal(obj.svd, obj.svd2)
#> [1] TRUE