Learn R Programming

bivarhr (version 0.1.5)

standardize_continuous_in_place: Standardize Continuous Columns In Place

Description

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".

Usage

standardize_continuous_in_place(DT, cols, center = TRUE, scale = TRUE)

Value

The modified data.table

DT (invisibly), with an attribute "standardization" containing the means, standard deviations, and names of the standardized columns.

Arguments

DT

A data.table. It is modified by reference.

cols

Character vector of column names to standardize. Columns that are not present in DT or are not numeric are silently skipped.

center

Logical; whether to subtract the column mean.

scale

Logical; whether to divide by the column standard deviation.

Examples

Run this code
# \donttest{
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")
# }

Run the code above in your browser using DataLab