Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

preprocess

Center, scale, and impute data


Description

A faster version of scale with a similar interface that also allows for imputation. The main difference is that this version scales by the standard deviation regardless of whether centering is enabled or not. If centering is enabled, missing values are imputed by 0, otherwise by the mean of the column that contains the value.

Usage

preprocess(X, center = FALSE, scale = FALSE, impute = FALSE)

Arguments

X

A numeric matrix.

center

Either a logical value or numeric vector of length equal to the number of columns of X.

scale

Either a logical value or numeric vector of length equal to the number of columns of X.

impute

Indicates whether missing values should be imputed.

Value

The centered, scaled, and imputed matrix.

See Also

scale, which this function tries to improve upon.

Examples

# Load example data
bg <- BGData:::loadExample()

# Center and scale genotypes
W <- preprocess(as.matrix(geno(bg)), center = TRUE, scale = TRUE)

BGData

A Suite of Packages for Analysis of Big Genomic Data

v2.2.0
MIT + file LICENSE
Authors
Gustavo de los Campos [aut], Alexander Grueneberg [aut, cre], Paulino Perez [ctb], Ana Vazquez [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.