Getting cumulative proportion in pca
r
Solution
You can try
pr <- prcomp(USArrests, scale = TRUE)
vars <- apply(pr$x, 2, var)
props <- vars / sum(vars)
cumsum(props)
Problem
I want to retrive the cumulative proportion of explained variance after a pca in R. `summary(pca)` returns this result in its last row, but how can I extract this row? ``` summary(prcomp(USArrests, scale = TRUE)) Importance of components: PC1 PC2 PC3 PC4 Standard deviation 1.5749 0.9949 0.59713 0.41645 Proportion of Variance 0.6201 0.2474 0.08914 0.04336 Cumulative Proportion 0.6201 0.8675 0.95664 1.00000 ``` I tried `s <- summary(prcomp(USArrests, scale = TRUE))` and s[3] etc, but it doesn't return the last row.