| stand {RVAideMemoire} | R Documentation |
Standardization of a data frame based on another data frame
Description
Centers and scales a data frame. See Details.
Usage
stand(tab, ref.tab=NULL, center=NULL, scale=NULL)
Arguments
tab |
data frame to scale. |
ref.tab |
optional reference data frame, from which centering and scaling parameters are obtained (see Details). |
center |
optional vector of centering parameters (one per column of |
scale |
optional vector of scaling parameters (one per column of |
Details
If ref.tab is not NULL, centering and scaling parameters are looked for into this data frame. If it has a "scaled:center" attribute, this one is used to center tab. Otherwise means of ref.tab's columns are used. The same happens for scaling parameters (with the "scaled:scale" attribute and standard deviations).
If ref.tab is NULL, values of center and scale are used to standardize tab.
If ref.tab and center are NULL, means of tab's columns are used for centering. If ref.tab and scale are NULL, standard deviations of tab's columns are used for scaling.
Author(s)
Maxime HERVE <maxime.herve@univ-rennes1.fr>
See Also
Examples
data(iris)
set.seed(1131)
iris.samp <- iris[sample(1:150,10),1:4]
# Centering parameters of the complete dataset
attr(scale(iris[,1:4]),"scaled:center")
# Centering parameters of the reduced dataset
attr(scale(iris.samp),"scaled:center")
# Standardization based on the reduced dataset only
attr(stand(iris.samp),"scaled:center")
# Standardization based on the complete dataset
attr(stand(iris.samp,iris[,1:4]),"scaled:center")