unscale: Reverse a scale

Description Usage Arguments Author(s) References See Also Examples

View source: R/unscale.R

Description

Computes x = sz+c, which is the inverse of z = (x - c)/s provided by the scale function.

Usage

1
unscale(z, center = attr(z, "scaled:center"), scale = attr(z, "scaled:scale"))

Arguments

z

a numeric matrix(like) object

center

either NULL or a numeric vector of length equal to the number of columns of z

scale

either NULL or a numeric vector of length equal to the number of columns of z

Author(s)

Neal Fultz

References

https://stackoverflow.com/questions/10287545/backtransform-scale-for-plotting/46840073

See Also

scale

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
 mtcs <- scale(mtcars)
 
 all.equal(
   unscale(mtcs), 
   as.matrix(mtcars), 
   check.attributes=FALSE
 )
 
 oldSeed <- .Random.seed
 z <- unscale(rnorm(10), 2, .5)
 .Random.seed <- oldSeed
 x <- rnorm(10, 2, .5)
 all.equal(z, x, check.attributes=FALSE)

nfultz/stackoverflow documentation built on Aug. 4, 2020, 5:31 a.m.