2013-10-22 2 views
1

내가 같은 테이블이 재구성 :data.frame

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.... 

나는 그 작업을 수행하는 방법을 모르는 내가 알지도 못하는 : 나는 싶어 무엇

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 

그것이 가능하다면 :).

install.packages("reshape2") 
library(reshape2) 
melt(df, measure.vars=2:7) 
+1

질문 무엇입니까? – Joren

+0

다음 번에 [코드 시도에 대한 해결책을 포함해야하며, 작동하지 않는 이유와 예상되는 결과가 포함되어야합니다.] – Henrik

답변

6

귀하의 질문은 완전히 명확하지 않습니다하지만 당신은이 라인을 따라 뭔가를하려고 :

+0

그래, 계산 해봐야 겠어. Anova 테스트 등. – Juanhijuan

+1

나는'Control1'이 id 여야한다고 생각하지 않습니다. –

+0

@ SeñorO, 네 말이 맞아. 지적 해 주셔서 고맙습니다. – TheComeOnMan

2

reshape2 패키지에서 melt 기능을 사용하여?

library(reshape2) 

melt(dt, id.vars = c('ID','Name')) 
0

기본 R에서 reshape 사용 :

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