R: Extract the results for individuals/variables - PCA

get_pca {factoextra} | R Documentation

## Extract the results for individuals/variables - PCA

### Description

Extract all the results (coordinates, squared cosine, contributions) for the active individuals/variables from Principal Component Analysis (PCA) outputs.

- get_pca(): Extract the results for variables and individuals

- get_pca_ind(): Extract the results for individuals only

- get_pca_var(): Extract the results for variables only

### Usage

    get_pca(res.pca, element = c("var", "ind"))

    get_pca_ind(res.pca, ...)

    get_pca_var(res.pca)

### Arguments

`res.pca` | an object of class PCA [FactoMineR]; prcomp and princomp [stats]; pca, dudi [adea4]; epPCA [ExPosition].
`element` | the element to subset from the output. Allowed values are "var" (for active variables) or "ind" (for active individuals).
`...` | not used

### Value

a list of matrices containing all the results for the active individuals/variables including:

`coord` | coordinates for the individuals/variables
`cos2` | cos2 for the individuals/variables
`contrib` | contributions of the individuals/variables

### Author(s)

Alboukadel Kassambara alboukadel.kassambara@gmail.com

### References

http://www.sthda.com/english/

### Examples

    # Principal Component Analysis
    # +++++++++++++++++++++++++++++
     data(iris)
     res.pca <- prcomp(iris[, -5],  scale = TRUE)
     # Extract the results for individuals
     ind <- get_pca_ind(res.pca)
     print(ind)
     head(ind$coord) # coordinates of individuals
     head(ind$cos2) # cos2 of individuals
     head(ind$contrib) # contributions of individuals

     # Extract the results for variables
     var <- get_pca_var(res.pca)
     print(var)
     head(var$coord) # coordinates of variables
     head(var$cos2) # cos2 of variables
     head(var$contrib) # contributions of variables

     # You can also use the function get_pca()
     get_pca(res.pca, "ind") # Results for individuals
     get_pca(res.pca, "var") # Results for variable categories

[Package factoextra version 1.0.5 Index]