Skip to content
Prev 26786 / 63424 Next

unexpected result from reshape

I got the problem: dataframe columns are re-ordered alfabetically, but
variable names aren't reordered accordingly in the resulting
dataframe. The problem disappears by specifying the 'varying' argument
as a named list:

d <- matrix(seq_len(7*7), 1, 7*7)
vnames <- c('acc','ppeGross','CF','ROA','DeltaSales','invTA','DeltaRevDeltaRec')
vnames.all <- unlist(lapply(vnames, paste, 1:7, sep='.'))
varying <- split(vnames.all, rep(vnames, each=7))
d <- data.frame(d)
names(d) <- vnames.all
d1 <- reshape(d, varying=varying, direction="long")
d
d1
#Now is ok

2007/11/24, Antonio, Fabio Di Narzo <antonio.fabio at gmail.com>: