Re: [R] function order

From: Philipp Pagel <p.pagel_at_wzw.tum.de>
Date: Wed, 06 Apr 2011 13:42:35 +0200

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/

______________________________________________
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.
Received on Wed 06 Apr 2011 - 11:45:27 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 06 Apr 2011 - 11:50:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive