# x dplyr::filter() masks stats::filter() We’ll also use the cowplot package for plot themes.
Note that as of this writing, we need the current development version of broom because of a bug in tidy.prcomp(). But now, I’ve realized that all the necessary functions to do this tidyverse-style are available in the broom package.įor our PCA example, we’ll need the packages tidyverse and broom. While it’s reasonably easy to extract the relevant info with some base-R manipulations, I’ve never been happy with this approach. The result is an object of class prcomp that doesn’t fit nicely into the tidyverse framework, e.g. for visualization. Doing a PCA in R is easy: Just run the function prcomp() on your matrix of scaled numeric predictor variables.