#' performs PCA on matrix X
#'
#' @param X matrix to apply PCA on
#' @param type PCA (no rescale) or SPCA (rescale)
#'
#' @return list of PCA parameters (PCs from X, mean, eigenvectors and values)
#' @importFrom stats prcomp
#' @export
pca <- function(X, type = 'SPCA') {
if (type == 'SPCA') scale = TRUE
if (type == 'PCA') scale = FALSE
modPCA <- stats::prcomp(X, scale = scale)
return(modPCA)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.