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

unscale

Reverse a scale


Description

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

Usage

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

See Also

Examples

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)

stackoverflow

Stack Overflow's Greatest Hits

v0.7.0
CC BY-SA 4.0
Authors
Neal Fultz <nfultz@gmail.com> and the StackOverflow.com community
Initial release
2020-01-03

We don't support your browser anymore

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