[R] reorder data.frame
    Johannes Radinger 
    JRadinger at gmx.at
       
    Wed Nov  9 16:14:03 CET 2011
    
    
  
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
--
    
    
More information about the R-help
mailing list