Extracts all factors of a principal component analysis of a matrix or data frame. Just a convenient wrapper for prcomp.

pca(
  x = NULL,
  colnames.prefix = "pca_factor"
)

Arguments

x

numeric matrix or data frame, Default: NULL

colnames.prefix

character, name prefix for the output columns, Default: 'pca_factor'

Value

A data frame with the PCA factors of x.

Details

Columns in x with zero variance are removed before computing the PCA.

Examples

if(interactive()){

 #load example distance matrix
 data(distance_matrix)

 #PCA of the distance matrix
 out <- pca(x = distance_matrix)
 out

}