prep | R Documentation |
Scaling and centering a matrix.
prep(object, scale = c("none", "pareto", "vector", "uv"),
center = TRUE, eps = 1e-12, simple = TRUE, reverse = FALSE, ...)
object |
Numerical matrix (or an object coercible to such)
with samples in rows and variables as columns. Also takes
|
scale |
One of "UV" (unit variance |
center |
Either a logical which indicates if the matrix
should be mean centred or not, or a vector with averages which
should be suntracted from the matrix. |
eps |
Minimum variance, variable with lower variance are not scaled and warning is issued instead. |
simple |
Logical indicating if only the data should be returned or a list with the pre-processing statistics as well. |
reverse |
Logical indicating if matrix should be 'post-processed' instead by multiplying each column with its scale and adding the center. In this case, center and scale should be vectors with the statistics (no warning is issued if not, instead output becomes the same as input). |
... |
Only used for passing through arguments. |
Does basically the same as scale
but adds some
alternative scaling options and functionality for treating
pre-processing as part of a model.
A pre-processed matrix or a list with
center |
a vector with the estimated centers |
scale |
a vector with the estimated scales |
data |
the pre (or post) processed data |
Henning Redestig
object <- matrix(rnorm(50), nrow=10)
res <- prep(object, scale="uv", center=TRUE, simple=FALSE)
obj <- prep(object, scale=res$scale, center=res$center)
## same as original
sum((object - prep(obj, scale=res$scale, center=res$center, rev=TRUE))^2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.