Skip to content
Back to formatted view

Raw Message

Message-ID: <20110406114235.GB5890@maker>
Date: 2011-04-06T11:42:35Z
From: Philipp Pagel
Subject: function order
In-Reply-To: <7785EFE1CC2D9F4A96F6A415BC1C2BD0168DD5C0@PC6-46.pogb.cancer.ucl.ac.uk>

On Wed, Apr 06, 2011 at 11:35:32AM +0100, Yan Jiao wrote:
> abc<-cbind(c(1,6,2),c(2,5,3),c(3,2,1))## matrix I want to sort
> 
> if I do
> abc[ order(abc[,3]), increasing = TRUE]

Jim already pointed out that the argument needs to go inside the
parenthes of the order function. In addition, order has an argument
called 'decreasing', but none called 'inceasing'. Finally, you are
lacking a comma in your subsetting of the matrix:

> abc[ order(abc[,3], decreasing=F)]
[1] 2 6 1

But you probably mean:

> abc[ order(abc[,3], decreasing=F), ]
     [,1] [,2] [,3]
[1,]    2    3    1
[2,]    6    5    2
[3,]    1    2    3

cu
	Philipp


-- 
Dr. Philipp Pagel
Lehrstuhl f?r Genomorientierte Bioinformatik
Technische Universit?t M?nchen
Wissenschaftszentrum Weihenstephan
Maximus-von-Imhof-Forum 3
85354 Freising, Germany
http://webclu.bio.wzw.tum.de/~pagel/