Your desired answer just interchanges the sequence of the steps

x <-  c(2, 9, 18, 3, 2)
y <-  c(2,9,8,9,8)
z <-  c(21,5,5,19,7)
a <-  cbind(x, y, z)  #dataset

bb <- a[order(a[,"x"], decreasing=FALSE),]
bbb <- bb[order(bb[,"y"], decreasing=TRUE),]
bbb

>From ?sort
Sort (or order) a vector or factor (partially) into ascending (or descending) 
order. For ordering 
along more than one variable, e.g., for sorting data frames, see order. 

>From ?order
order returns a permutation which rearranges its first argument into ascending 
or descending 
order, breaking ties by further arguments. 


tmp <- c(10,15,12,7)
sort(tmp)
order(tmp)
tmp[order(tmp)]

______________________________________________
[email protected] 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