| standardize_continuous_in_place | R Documentation |
Standardizes selected numeric columns of a data.table in place using
a z-score transformation. The function modifies DT by reference
and stores the means and standard deviations used in an attribute
called "standardization".
standardize_continuous_in_place(DT, cols, center = TRUE, scale = TRUE)
DT |
A |
cols |
Character vector of column names to standardize. Columns
that are not present in |
center |
Logical; whether to subtract the column mean. |
scale |
Logical; whether to divide by the column standard deviation. |
The modified data.table DT (invisibly), with an
attribute "standardization" containing the means, standard
deviations, and names of the standardized columns.
library(data.table)
DT <- data.table(x = rnorm(10), y = runif(10), z = 0:9)
standardize_continuous_in_place(DT, c("x", "y"))
attr(DT, "standardization")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.