std.data: Standardization of the Data

View source: R/std.data.R

std.dataR Documentation

Standardization of the Data

Description

Chosen columns of a data.frame are standardized by using a sample mean and sample standard deviation.

Usage

std.data(datain, cols)

Arguments

datain

Input data frame.

cols

A character vector with names of the columns to be standardized.

Details

For each chosen column the sample mean and the sample standard deviation is computed and then used to standardize the column. Missing values are ignored when computing the mean and the standard deviation.

Value

A data.frame with same variables as the input data.frame. Chosen columns are standardized.

Author(s)

Arnošt Komárek arnost.komarek@mff.cuni.cz

See Also

scale

Examples

variable1 <- rnorm(30)
variable2 <- rbinom(30, 1, 0.4)
variable3 <- runif(30)
data.example <- data.frame(variable1, variable2, variable3)
## We standardize only the first and the third column.
data.std <- std.data(data.example, c("variable1", "variable3"))
print(data.std)
print(c(mean(data.std$variable1), sd(data.std$variable1)))
print(c(mean(data.std$variable3), sd(data.std$variable3)))

smoothSurv documentation built on Oct. 11, 2022, 1:05 a.m.