我個人從四個羣體,四個處理和三次重複的數據集。每個人只有一個人口,治療和複製組合。我從每個人身上取得了四次測量結果。我想針對每個羣體,底物和重複組合對這些測量進行PCA。如何針對具有多個組的數據集對每個組進行PCA?
我意識到如何對所有個體做PCA,我可以將數據集分成多個數據集,用於羣體,底物和複製的每個組合,然後在每個新數據集上執行PCA。
我怎樣才能在完整的數據集獲得獨立的PC1,PC2 ...結果的人羣中,基材每個組合進行PCA,並複製最有效?我有一個關於將數據集轉換爲列表的想法,但不確定如何將princomp函數應用於列表。我在正確的軌道上嗎?
的樣本數據:
TestData<- structure(list(Location = c("A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A",
"B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B",
"C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C",
"D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D"),
Substrate = c("A", "B", "C", "D", "A", "B", "C", "D", "A", "B", "C", "D",
"A", "B", "C", "D", "A", "B", "C", "D", "A", "B", "C", "D",
"A", "B", "C", "D", "A", "B", "C", "D", "A", "B", "C", "D",
"A", "B", "C", "D", "A", "B", "C", "D", "A", "B", "C", "D"),
Replicate = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L),
Adult_Weight = c(0.0092, 0.0083, 0.0088, 0.0077, 0.0088, 0.01,
0.0099, 0.011, 0.0078, 0.0086, 0.0071, 0.0093,
0.0111, 0.01, 0.0097, 0.0091, 0.0083, 0.0098,
0.0093, 0.009, 0.0114, 0.0087, 0.0094, 0.0096,
0.0099, 0.0105, 0.0091, 0.0115, 0.0106, 0.0104,
0.0113, 0.0115, 0.0107, 0.0126, 0.0106, 0.0101,
0.0095, 0.0113, 0.0111, 0.0118, 0.0114, 0.0123,
0.0119, 0.0103, 0.0119, 0.0116, 0.0112, 0.0114),
Adult_Thorax_Width = c(1.31, 1.31, 1.43, 1.45, 1.52, 1.43, 1.57, 1.45, 1.43, 1.54, 1.32, 1.49,
1.58, 1.36, 1.42, 1.45, 1.48, 1.38, 1.55, 1.46, 1.52, 1.42, 1.6, 1.49,
1.48, 1.58, 1.51, 1.53, 1.54, 1.76, 1.63, 1.62, 1.44, 1.51, 1.53, 1.58,
1.46, 1.94, 1.54, 2.09, 1.5, 1.65, 1.86, 1.54, 1.8, 1.98, 1.82, 1.63),
Adult_Wing_Length = c(1359L, 1377L, 1555L, 1559L, 1562L, 1578L, 1580L, 1588L, 1597L, 1598L, 1603L, 1605L,
1612L, 1614L, 1616L, 1617L, 1623L, 1628L, 1639L, 1642L, 1643L, 1649L, 1651L, 1652L,
1653L, 1653L, 1654L, 1656L, 1656L, 1656L, 1662L, 1664L, 1665L, 1668L, 1670L, 1670L,
1671L, 1672L, 1674L, 1682L, 1685L, 1687L, 1688L, 1694L, 1698L, 1698L, 1707L, 1708L),
Adult_Leg_Length = c(414L, 390L, 627L, 541L, 430L, 450L, 451L, 462L, 443L, 582L, 435L, 579L,
499L, 418L, 444L, 646L, 589L, 466L, 435L, 477L, 450L, 606L, 660L, 450L,
446L, 480L, 462L, 438L, 483L, 454L, 492L, 457L, 463L, 499L, 470L, 474L,
627L, 478L, 473L, 496L, 666L, 499L, 480L, 461L, 450L, 483L, 460L, 584L)),
.Names = c("Location", "Substrate", "Replicate", "Weight", "Thorax_Width", "Wing_Length", "Leg_Length"),
row.names = c(NA, 48L),
class = "data.frame")
如果您提供了一個虛擬數據集,我會告訴你如何。 – 2014-10-10 11:00:53