R/pca.R

Defines functions pca

Documented in pca

#' 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)
}
jbferet/biodivMapR documentation built on April 12, 2025, 1:32 p.m.