[R] Inverting data frame...row wise
Daniel Malter
daniel at umd.edu
Thu Sep 25 23:37:16 CEST 2008
So you want to make columns
1,2,3,4
into
4,3,2,1
or into
4,1,2,3?
The first option is done by:
x=c(rep(1,10),rep(2,10),rep(3,10),rep(4,10))
dim(x)=c(10,4)
x=data.frame(x) #create data
x2=x[,order(-1:-4)] #invert column order
-------------------------
cuncta stricte discussurus
-------------------------
-----Ursprüngliche Nachricht-----
Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im
Auftrag von milicic.marko
Gesendet: Thursday, September 25, 2008 5:24 PM
An: r-help at r-project.org
Betreff: [R] Inverting data frame...row wise
Hi,
I have the data.frame with 4 columns. I simply want to invert dataset so
that last row becomes first...
I tried with rev(my_data-frame) but I got my columns inverted... not my rows
Thanks
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list