#' 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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.