Re: [R] How to transform: 4 columns into two columns stacked

2010-07-16 Thread Eik Vettorazzi
its maybe not as simple as Teds solution but points to a more general approach reshape(mydata,direction="long",varying=names(mydata),v.names=c("id","x","y")) Am 16.07.2010 13:27, schrieb Ralf B: > I have the following data structure: > > n=5 > mydata <- data.frame(id=1:n, x=rnorm(n), y=rnorm(n),

Re: [R] How to transform: 4 columns into two columns stacked

2010-07-16 Thread Ted Harding
On 16-Jul-10 11:27:18, Ralf B wrote: > I have the following data structure: > > n=5 > mydata <- data.frame(id=1:n, x=rnorm(n), y=rnorm(n), id=1:n, > x=rnorm(n), y=rnorm(n)) > print(mydata) > > producing the following represention > > id x y id.1 x.1y.1 > 1 1 0.

[R] How to transform: 4 columns into two columns stacked

2010-07-16 Thread Ralf B
I have the following data structure: n=5 mydata <- data.frame(id=1:n, x=rnorm(n), y=rnorm(n), id=1:n, x=rnorm(n), y=rnorm(n)) print(mydata) producing the following represention id x y id.1 x.1y.1 1 1 0.5326855 -2.076337031 0.7930274 -1.0530558 2 2 0.78889