"Ng Stanley" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]:
> 2) I have looked deeply into R, but can't fine multi-level sorts. At the top of the help page for 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_. " In the examples on the order page, it shows what I suspect you mean by a multilevel sort (although you offer no examples). > (ii <- order(x <- c(1,1,3:1,1:4,3), y <- c(9,9:1), z <-c(2,1:9))) [1] 6 5 2 1 7 4 10 8 3 9 > dd <- transform(data.frame(x,y,z), + z = factor(z, labels=LETTERS[9:1])) > dd x y z 1 1 9 H 2 1 9 I 3 3 8 H 4 2 7 G 5 1 6 F 6 1 5 E 7 2 4 D 8 3 3 C 9 4 2 B 10 3 1 A > dd[ order(x, -y, z) ,] x y z 2 1 9 I 1 1 9 H 5 1 6 F 6 1 5 E 4 2 7 G 7 2 4 D 3 3 8 H 8 3 3 C 10 3 1 A 9 4 2 B -- David Winsemius > > 3) I have a vector of words, several of which need to be replaced by > different unique words. I am using multi-lines of gsub, is there any > elegant alternative ? > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.