I was trying to use the reshape-function to reshape a data.frame from wide to long format. I was following an example Reshaping wide to long with multiple values columns, but the correct answer seems not to work for me.
It seems that the problem is, that reshape only works, if the names of the columns are in alphabetical order. I rewrote the example a little bit, to explain the problem. As you can see, in the reformatted table, the values of the columns are switched. Values from "avg" are in "asd" and vice versa.
Is this a bug, or am I thinking wrong?
Greeting, Silke
dw <- read.table(header=T, text='
sbj f1.avg f1.asd f2.avg f2.asd blabla
A 10 6 50 10 bA
B 12 5 70 11 bB
C 20 7 20 8 bC
D 22 8 22 9 bD
')
reshape(dw, direction='long',
varying=c('f1.avg', 'f1.asd', 'f2.avg', 'f2.asd'),
timevar='var',
times=c('f1', 'f2'),
v.names=c('avg', 'asd'),
idvar='sbj')