select_pcs returns a list of principal components as chosen by one of three methods (from D.A. Jackson (1993). Ecology, 74, 2204-2214).

select_pcs(
  pca_output,
  method = c("broken_stick", "kaiser_guttman", "total_variance"),
  total_var = 0.95
)

Arguments

pca_output

Output from gm.prcomp or prcomp

method

Method used to select PCs. Defaults to the most conservative "broken_stick". Other methods are "kaiser_guttman" (PCs with eigenvalues greater than the mean eigenvalue) and "total_variance" (PCs explaining at least total_var variance)

total_var

Total variance to choose for "total_variance" method. Defaults to .95

Value

Returns selected PCs and variance explained

Note

Code for "broken_stick" method adapted from function "evplot" by Francois Gillet.