scaleToUnit | R Documentation |
scaleToUnit
scales the columns of a numeric matrix to
the unit range.
scaleToUnit(x, min = 0,
max = 1, center = TRUE,
solveSingular = TRUE)
x |
a numeric matrix |
min |
the minimum in each dimension to scale to (defaults to
|
max |
the maximum in each dimension to scale to (defaults to
|
center |
shift and scale values to fit in the desired interval, or only scale them (and keep the mean fixed)? |
solveSingular |
if |
Scaled x
. The desired minimum and maximum values
are returned as attributes min
and max
,
respectively. The minimum/maximum values of x
are returned
as attributes min_x
and max_x
, respectively. The
function used to transform a row in x
to the desired range
is returned as the tx
attribute. The inverse transform can
be find in the txInv
attribute.
Tomas Sieger
# scale the \code{iris} data set
x <- iris[, 1:4]
summary(x)
x2 <- scaleToUnit(x)
summary(x2)
# transform explicitly:
x2[1, ]
attr(x2, 'tx')(iris[1, 1:4])
# inverse transform:
y <- cbind(1:4,1)
y
y2 <- scaleToUnit(y ,min = 0, max = 1)
y2
y3 <- attr(y2, 'txInv')(y2)
y3
# scale, but not center
scaleToUnit(1:10, min = -1, max = 1, center = FALSE)
scaleToUnit(-2:5, min = -1, max = 1, center = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.