R/stdz_xy.R

Defines functions stdz_xy

Documented in stdz_xy

#' Standardize x and y vectors to achieve zero mean and unit variance.
#'
#' @param x Vector of data which can have NA's
#' @param y  Vector of data which can have NA's
#' @importFrom stats sd
#' @return
#' \item{stdx}{standardized values of x}
#' \item{stdy}{standardized values of y}
#' @author Prof. H. D. Vinod, Economics Dept., Fordham University, NY
#' @note This works even if there are missing x or y values.
#' @examples
#'
#' \dontrun{
#' set.seed(30)
#' x=sample(20:30)
#' y=sample(21:31)
#' stdz_xy(x,y) }
#'
#' @export

stdz_xy <- function(x, y) {
    stdx = (x - mean(x, na.rm = TRUE))/sd(x, na.rm = TRUE)
    stdy = (y - mean(y, na.rm = TRUE))/sd(y, na.rm = TRUE)
    list(stdx = stdx, stdy = stdy)
} 

Try the generalCorr package in your browser

Any scripts or data that you put into this service are public.

generalCorr documentation built on Oct. 10, 2023, 1:06 a.m.