unscale: Unscale a matrix

View source: R/unscale.R

unscaleR Documentation

Unscale a matrix

Description

The unscale function unscales a numeric marteix that has been either centered or scaled by the scale function. This is done by reversing the first unscaling and then uncentering based on the object's attributes.

Usage

unscale(x, unscale = TRUE, uncenter = TRUE)

Arguments

x

a numeric matrix(like object) that has been centered and/or scaled by the scale function.

unscale

a logical value defining whether to unscale x.

uncenter

a logical value defining whether to uncenter x.

Examples

x <- matrix(1:16, 4, 4)
xcs <- scale(x, center=TRUE, scale=TRUE) # centered and scaled
xc <- scale(x, center=TRUE, scale=FALSE) # centered only
xs <- scale(x, center=FALSE, scale=TRUE) # scaled only

# compare difference to original
x - unscale(xcs)
x - unscale(xc)
x - unscale(xs)


marchtaylor/sinkr documentation built on July 4, 2022, 5:48 p.m.