scale0: center and normalize a vector to 1 or to (N - 1)

View source: R/testMC.R

scale0R Documentation

center and normalize a vector to 1 or to (N - 1)

Description

center and normalize a vector to 1 or to (N - 1)

Usage

scale0(x, center = TRUE, scale = "SS1")

Arguments

x

a vector with N elements.

center

if TRUE (Default) center if not do nothing.

scale

if FALSE do nothing, if TRUE normalize like Z-scores (i.e., norm = N - 1), if 'SS1' (Default) normalize to 1 (i.e., norm = 1).

Details

When x comprises different values scale0 gives the same results as scale except for the option 'SS1'; when x comprises all identical values and when the paramater scale = TRUE, scale gives back a vector of NaN (because of a division by 0 error), whereas scale0 gives back a vector of 0.

Value

a scaled version of x.

Author(s)

Hervé Abdi

See Also

scale

Examples

y <- scale0(c(1,2,5,10))


HerveAbdi/data4PCCAR documentation built on Sept. 11, 2022, 4:19 p.m.