R/scale.r

Defines functions scale2

Documented in scale2

#' Scale
#' 
#' An efficient method of centering and/or scaling a matrix or vector.
#' Like R's own \code{scale()}, this will cast dataframes as matrices
#' first, which is potentially a very memory expensive operation.
#' 
#' @param x
#' The input matrix, vector, or dataframe.
#' @param center
#' Logical; should the data be centered first? (yes!)
#' @param scale
#' Logical; should the data be scaled first? (probably!)
#' 
#' @rdname scale
#' @export
scale2 <- function(x, center=TRUE, scale=TRUE)
{
  assert.type(center, "logical")
  assert.type(scale, "logical")
  check_mvdf(x)
  
  assert.type(x, "numeric")
  if (!is.double(x))
    storage.mode(x) <- "double"
  
  .Call(R_scale, as.logical(center), as.logical(scale), x)
}
wrathematics/pcapack documentation built on May 4, 2019, 10:53 a.m.