CommencerCommencer gratuitement

Summarizing PCA in R

As we saw in the video, there was a categorical variable (position) in our data that seemed to identify itself with clusters in the first two principal components. Even when scaling the data, these two PCs still explain a great deal of variation in the data. What if we looked at only one position at a time?

Cet exercice fait partie du cours

Linear Algebra for Data Science in R

Afficher le cours

Instructions

Perform the same analysis as in the previous exercise, but only use the subset of the data where position equals "WR" (wide receiver):

  • Use the scale() function to scale the 5th through the 12th columns of combine_WR data. Name this data frame B and show some of the values using head().
  • Use prcomp() to perform principal component analysis on the data and summarize this analysis using summary().

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Subset combine only to "WR"
combine_WR <- subset(combine, position == "WR")

# Scale columns 5-12 of combine_WR
B <- ___(___[, ___])

# Print the first 6 rows of the data
___

# Summarize the principal component analysis
___(___)
Modifier et exécuter le code