Message-ID: <20111109151403.72940@gmx.net>
Date: 2011-11-09T15:14:03Z
From: Johannes Radinger
Subject: reorder data.frame
In-Reply-To: <Prayer.1.3.2.1111091433180.31011@webmail4.york.ac.uk>
Hello,
I very general question but probably usefull to others as well:
Is there any prebuild function that reorders a dataframe from:
x1 x2
1 100 200
2 101 201
3 102 202
4 103 203
5 104 204
6 105 205
to
1 100 x1
2 101 x1
3 102 x1
4 103 x1
5 104 x1
6 105 x1
7 200 x2
8 201 x2
9 202 x2
10 203 x2
11 204 x2
12 205 x2
I found a way with:
names <- rep(c("x1","x2"),c(length(x1),length(x2)))
x <-c(x1,x2)
data.frame(x,names)
but probably there is already another function for doing such things more easily.
Thank you
Johannes
--