MulaiMulai sekarang secara gratis

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?

Latihan ini adalah bagian dari kursus

Linear Algebra for Data Science in R

Lihat Kursus

Petunjuk latihan

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().

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# 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
___(___)
Edit dan Jalankan Kode