> mylist <- c( 2,1,3,5,4 )        <<< make a vector of numbers
> sort(mylist)
[1] 1 2 3 4 5                           <<< in sorted order

> mylist <- c( "this", "is", "a", "test")
> sort(mylist)
[1] "a"    "is"   "test" "this"      <<< in sorted order
> order(mylist)
[1] 3 2 4 1                     <<< original positions, e.g. mylist[3] is "a"


On Sat, Apr 18, 2009 at 10:46 AM, Dan Cary <daniel_c...@hotmail.co.uk> wrote:
> ...all i want to know is how to arrange a set of numbers in size order 
> without putting them in a table. just arranging them from for e.g. 2,1,3,5,4 
> into 1,2,3,4,5 - it must be simple but i cant find how to do it anywhere

______________________________________________
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