# NOT RUN {
library(parameters)
if (require("psych")) {
  principal_components(mtcars[, 1:7], n = "all", threshold = 0.2)
  principal_components(mtcars[, 1:7], n = 2, rotation = "oblimin",
                       threshold = "max", sort = TRUE)
  principal_components(mtcars[, 1:7], n = 2, threshold = 2, sort = TRUE)
  pca <- principal_components(mtcars[, 1:5], n = 2, rotation = "varimax")
  summary(pca)
  predict(pca)
  # which variables from the original data belong to which extracted component?
  closest_component(pca)
# }
# NOT RUN {
  # Automated number of components
  principal_components(mtcars[, 1:4], n = "auto")
# }
# NOT RUN {
}
# }
Run the code above in your browser using DataLab