检索R中的主要组件

时间:2014-05-26 07:51:44

标签: r pca

我正在使用prcomp函数在R中应用pca。调用summary(mypca)会重新调整组件的重要性(解释的方差比例),但我找不到检索这些主要组件的方法。有办法吗?

2 个答案:

答案 0 :(得分:2)

str(mypca)会指向x组件

prcomp(USArrests, scale = TRUE)$x
                       PC1         PC2         PC3          PC4
Alabama        -0.97566045  1.12200121 -0.43980366  0.154696581
Alaska         -1.93053788  1.06242692  2.01950027 -0.434175454
Arizona        -1.74544285 -0.73845954  0.05423025 -0.826264240
Arkansas        0.13999894  1.10854226  0.11342217 -0.180973554
California     -2.49861285 -1.52742672  0.59254100 -0.338559240
Colorado       -1.49934074 -0.97762966  1.08400162  0.001450164
Connecticut     1.34499236 -1.07798362 -0.63679250 -0.117278736
Delaware       -0.04722981 -0.32208890 -0.71141032 -0.873113315
Florida        -2.98275967  0.03883425 -0.57103206 -0.095317042

答案 1 :(得分:1)

我想你正在寻找$rotation

res <- prcomp(USArrests, scale = TRUE)
res$rotation

#                 PC1        PC2        PC3         PC4
# Murder   -0.5358995  0.4181809 -0.3412327  0.64922780
# Assault  -0.5831836  0.1879856 -0.2681484 -0.74340748
# UrbanPop -0.2781909 -0.8728062 -0.3780158  0.13387773
# Rape     -0.5434321 -0.1673186  0.8177779  0.08902432