#' @title Faster version for scale function
#'
#' @description Does the thing as \code{scale()} but faster.
#' @details Uses colSds() from \code{matrixStats} package.
#' @param x A matrix; \code{is.matrix(x)} should be \code{TRUE}.
#' @return A matrix in which columns are centered to have zero mean and scaled to have sd one.
#' @importFrom matrixStats colSds
#' @export
scalefaster <- function (x) {
a <- colMeans(x)
b <- colSds(x)
x <- t(t(x) - a)
x <- t(t(x) / b)
return(x)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.