I want to reshape this table:
data<-read.table(header=T, text=c("
X T V W
0 a g m
0 b h n
0 c i o
1 d j p
1 e k q
1 f l r "))
To
X T1 T2 T3 V1 V2 V3 W1 W2 W3
0 a b c g h i m n o
1 d e f j k l p q r
So we take only the first observations of each group in X and transpose corresponding values in T, V and W into columns.
Note that I have almost 2000 groups of repeated values in X (000, 111, 222, ... ) and I need to know how to reshape it with R. It means I start with 6000 rows to obtain after reshaping 2000 rows but the remaing 2 values of each group in T, V and W have to be transposed in new columns T2, T3, etc.
Thanks!