0

私は次の表を持っています

structure(list(Compound = structure(c(1L, 2L, 3L, 1L, 1L, 3L), .Label = c("Nap", 
"Phe", "tre"), class = "factor"), Area = c(17197669L, 19464754L, 
35792660L, 10097291L, 348395L, 2576352L), Samples = structure(c(1L, 
1L, 1L, 2L, 3L, 2L), .Label = c("a1", "a2", "a3"), class = "factor")), .Names = c("Compound", 
"Area", "Samples"), class = "data.frame", row.names = c(NA, -6L
))

このように再注文したい

structure(list(Compound = structure(1:3, .Label = c("Nap", "Phe", 
"tre"), class = "factor"), a1 = c(17197669L, 19464754L, 35792660L
), a2 = c(10097291L, 0L, 2576352L), a3 = c(348395L, 0L, 0L)), .Names = c("Compound", 
"a1", "a2", "a3"), class = "data.frame", row.names = c(NA, -3L
))

なにか提案を?どうやって始めたらいいのかわからない。

4

1 に答える 1

2

が最初のテーブルである場合dataは、次から始めることができます。

reshape(data,idvar="Compound",timevar="Samples",direction="wide")

詳細?reshapeについては、を参照してください。

于 2013-02-25T19:04:46.987 に答える