zt: Extended function for z-transformation, filling non-finite...

View source: R/int.R

ztR Documentation

Extended function for z-transformation, filling non-finite values and changes column names at will

Description

An extended function of the standard z-score standardization of a vector in R (i.e. function 'scale'). Supports filling in non-finite values as well as re-naming variables to distinguish them from non-standardized variables.

Usage

zt(x, fillfinite = 0, addz = T, saveattr = T)

Arguments

x

A data matrix for which the columns are to be standardized

fillfinite

The value to fill non-finite values with, by default zero.

addz

Boolean indicating whether letter 'z' should be appended to the variable names to indicate the standardization

saveattr

Boolean for if an 'attr' should be attached to the standardized vector, similar to how the R default function 'scale' conserves the centering and scaling values

Value

z-score standardized values (zero mean and unit variation), with non-finite values imputed by zero by default.

Examples

somedata <- cbind(rnorm(100), runif(100))
normdata <- zt(somedata)
head(normdata)
apply(normdata, MARGIN=2, FUN=mean)
apply(normdata, MARGIN=2, FUN=sd)

Syksy/ePCR documentation built on Feb. 20, 2024, 10:16 p.m.