Learn R Programming

mfp2 (version 1.0.0)

center_matrix: Simple function to center data

Description

Simple function to center data

Usage

center_matrix(mat, centers = NULL)

Value

Transformed data matrix. Has an attribute scaled:center that stores values used for centering.

Arguments

mat

a transformed data matrix.

centers

a vector of centering values. Length must be equal to the number of columns in mat. If NULL (default) then centering values are determined by the function (see Details).

Details

Centering is done by means for continuous variables (i.e. more than 2 distinct values), and the minimum for binary variables.

It is assumed all categorical variables in the data are represented by binary dummy variables.

Examples

Run this code
mat = matrix(1:100, nrow = 10)
center_matrix(mat)

Run the code above in your browser using DataLab