This function is used to standardize data by mean centering and dividing by the standard deviation.

stndrd(vars, data, center = "mean")

Arguments

vars

A character or vector equal to the names of the column(s) of the variables to be standardized

data

A data frame that holds the variables to be standardized

center

A character equal to 'mean', 'min', 'max' or a conditional (e.g. 'Year == 2015' or 'Sample == "D-4"') that sets the value on which the data should be centered. Default is center = 'mean'

Value

A the same data frame as data but with the data in the vars column(s) standardized

Examples

if (FALSE) {

set.seed(1)
df <- data.frame(X = rnorm(10, mean = 3, sd = 2),
                 Y = rnorm(10, mean = 5, sd = 0.5))

s.df <- stndrd(vars = c('X', 'Y'), data = df, center = 'mean')

}