An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090418/9beca084/attachment-0001.pl>
(no subject)
3 messages · Dan Cary, Ranjan Maitra, Stavros Macrakis
Welcome to R! I don't quite know what you mean by size order. But if you have five numbers: a <- c(2, 1, 3, 5, 4) then sort(a) will do what you want? HTH! Ranjan On Sat, 18 Apr 2009 14:46:04 +0000 Dan Cary <daniel_cary at hotmail.co.uk> wrote:
Hi, as a newcomer to R i have what probably is a very simple issue but i have been to solve it for hours: 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 thanksdan
_________________________________________________________________ [[elided Hotmail spam]] [[alternative HTML version deleted]] ______________________________________________ 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.
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_cary at 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