arrests <- as_tibble(USArrests, rownames = "state")
crime <- arrests |> select(-state)
pca <- prcomp(crime, scale. = TRUE)
# flip Z1 so a higher score = more crime
pca$rotation[, 1] <- -pca$rotation[, 1]
pca$x[, 1] <- -pca$x[, 1]
summary(pca)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








