Erik Iverson wrote:
I think you want ?order


On second read, I think you want to do this without having to specify all 18 variables in an order call... something like this (with only 3 variables)

v1 <- sample(rep(1:10, each = 2))
v2 <- sample(1:20)
v3 <- sample(1:20)
tmp <- data.frame(v1, v2, v3)

tmp[do.call(order, as.list(tmp)),]

The data.frame tmp is my sample data.frame, and notice how the last line I posted sorts by all columns without referencing the number of columns.

Hope that helps!
Erik


Hi, I have a data frame read from a .csv file, with columns V1,V2,V3...,V18, per say, and I want to sort this data frame according to V1, and then V2, then V3..., and so on. Is there any fast way to get around with this problem?
Thanks.

-JJ

______________________________________________
R-help@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.

______________________________________________
R-help@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.

______________________________________________
R-help@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.

Reply via email to