R/standardize.R

Defines functions standardize

Documented in standardize

#' Subtract the mean and divide by the standard deviation
#'
#' @import stats
#'
#' @param x vector to be standardized
#'
#' @return vector of same length of x with mean subtracted and divided
#'             through by the variance
#' @export
#'
standardize <- function(x){

  if(!is.numeric(x)) stop('input is not of type numeric')

  (x - mean(x)) / sd(x)
}
jlivsey/livsey documentation built on Oct. 17, 2024, 3:18 a.m.