It's been a long time since this topic was posted, but I recently had
occasion to use stats::reshape again. This time, I looked closer at the
code for the function so I could understand what was going on.
I now realize that if the argument varying is a vector of names (as I
had) rather than a
Hello,
A quick question for my edification. When I run the following (R 2.8.1 on
Microsoft Windows):
d = data.frame(x1=c(1,2),x2=c(3,4),y1=c(5,6),y2=c(7,8))
reshape(d,varying=c(y1,x1,y2,x2),v.names=c(y,x),dir=long)
I found myself surprised by the results--the column labeled y is actually
the
It seems that we can't change the order of varying argument or v.names.
Notice that the order of variables in varying is like x.1,y.1,x.2,y.2.
Code can only be:
reshape(d,varying=c(x1,y1,x2,y2),v.names=c(x,y),dir=long)
-
A R learner.
--
View this message in context:
Hi:
Is this what you were aiming for?
reshape(d,varying=list(c(x1,x2),
c(y1,y2)),v.names=c(x,y),dir=long)
time x y id
1.11 1 5 1
2.11 2 6 2
1.22 3 7 1
2.22 4 8 2
HTH,
Dennis
On Fri, Aug 6, 2010 at 10:28 AM, Krishna Tateneni taten...@gmail.comwrote:
Hello,
A quick
Thanks for the reply, I realize that having x and y in that order in
varying and v.names will work. The question is why reversing the order
(i.e., y followed by x) does not work; it seems unintuitive, so I'm
wondering if I've just misread the documentation.
On Fri, Aug 6, 2010 at 1:45 PM, Dennis
5 matches
Mail list logo