as_scaling_fun: Scaling function creator

View source: R/utils.R

as_scaling_funR Documentation

Scaling function creator

Description

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

Usage

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
fun.scaling2 <- as_scaling_fun(1:6, 2:7, ind.col = 6:1)
fun.scaling2(NULL, NULL, 1:3)


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)


bigstatsr documentation built on Oct. 14, 2022, 9:05 a.m.