開始使用免費開始

使用 princomp 函式

在這個練習中,你會使用 princomp() 函式來計算資料集的主成分(PC)。本章接下來的內容都會使用在此練習中建立的 pca.state 物件。

本練習屬於課程

R 的多變量機率分配

檢視課程

練習說明

  • 根據相關矩陣計算 state.x77 資料集的主成分與其分數(scores),並將結果儲存為 pca.state
  • 繪製圖形,並列印主成分物件的摘要。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Calculate PCs
pca.state <- princomp(___, cor = ___, scores = ___) 

# Plot the PCA object  
plot(___) 

# Print the summary of the PCs
summary(___) 
編輯並執行程式碼