데이터 확인
USArrests
Murder Assault UrbanPop Rape Alabama 13.2 236 58 21.2 Alaska 10.0 263 48 44.5 Arizona 8.1 294 80 31.0 Arkansas 8.8 190 50 19.5
표준화하기
scale(USArrests)
Murder Assault UrbanPop Rape Alabama 1.24256408 0.78283935 -0.52090661 -0.003416473 Alaska 0.50786248 1.10682252 -1.21176419 2.484202941 Arizona 0.07163341 1.47880321 0.99898006 1.042878388 Arkansas 0.23234938 0.23086801 -1.07359268 -0.184916602
표준화하여 주성분분석하기
arrest.pca = prcomp(USArrests, scale. = T)
summary(arrest.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
시각화
biplot(arrest.pca)