-1

私はこのようなテーブルを持っています:

Id Control1 Control2 Control2 Treat1  Treat2 Treat3 Name
5    34,5     44,5     43,2     67,4    55,6   76,6 Leptin
8    55         34     41,5     61,4    58,6   65,7 Grazin
9    25         33     48,5     63,1    52,3   61,3 Osey

それが私が取得したいものです:

Id 
 5  34,5 Leptin Control1
 5  44,5 Leptin Control2
 5  43,2 Leptin Control3
 5  67,4 Leptin Treat1
 5  55,6 Leptin Treat2
 5  76,6 Leptin Treat3
 and so on....

私はそれを行う方法がわかりませんし、それが可能かどうかさえわかりません:)。

4

3 に答える 3

6

Your question is not completely clear but are you trying to do something along these lines?

library(reshape2)

melt(dt, id.vars = c('ID','Name'))
于 2013-10-22T14:58:21.387 に答える
2

Use the melt function from the reshape2 package:

install.packages("reshape2")
library(reshape2)
melt(df, measure.vars=2:7)
于 2013-10-22T14:58:03.577 に答える
0

reshapeベースRから使用:

reshape(df1,varying=names(df1)[2:7],times=names(df1)[2:7],v.names="value",direction="long")
             Id   Name       time value id
1.Control1    5 Leptin   Control1  34,5  1
2.Control1    8 Grazin   Control1    55  2
3.Control1    9    Ose   Control1    25  3
1.Control2    5 Leptin   Control2  44,5  1
2.Control2    8 Grazin   Control2    34  2
3.Control2    9    Ose   Control2    33  3
1.Control2.1  5 Leptin Control2.1  43,2  1
2.Control2.1  8 Grazin Control2.1  41,5  2
3.Control2.1  9    Ose Control2.1  48,5  3
1.Treat1      5 Leptin     Treat1  67,4  1
2.Treat1      8 Grazin     Treat1  61,4  2
3.Treat1      9    Ose     Treat1  63,1  3
1.Treat2      5 Leptin     Treat2  55,6  1
2.Treat2      8 Grazin     Treat2  58,6  2
3.Treat2      9    Ose     Treat2  52,3  3
1.Treat3      5 Leptin     Treat3  76,6  1
2.Treat3      8 Grazin     Treat3  65,7  2
3.Treat3      9    Ose     Treat3  61,3  3
于 2013-10-22T15:05:37.090 に答える