Learn R Programming

smoothSurv (version 2.6)

std.data: 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)

Value

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

Arguments

datain

Input data frame.

cols

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

Author

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

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.

See Also

Examples

Run this code
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)))

Run the code above in your browser using DataLab