Re: [R] Rank Values in a Matrix

From: Naira Naouar <nanao_at_psb.ugent.be>
Date: Mon, 19 May 2008 14:15:17 +0200

Hi Jens,

If the matrix you described is m.

Then, you can do
 > unique(as.vector(m))
[1] 0.1 2.0 0.0 3.0 50.0 1.0 100.0  > order(unique(as.vector(m)))
[1] 3 1 6 2 4 5 7

Hope this helps :)

Naira

Jens Oldeland wrote:
> Dear All,
>
> a short and maybe simple question:
>
>
> I have to rank all values in a matrix from 0 to X,
>
> [1] [2] [3] [4]
> [1] 0.1 2 0 3
> [2] 50 3 3 1
> [3] 100 1 1 0
> [4] 100 2 2 0
>
> 0->0
> 0.1->1
> 2->2
> 3->3
> 50->4
> 100->5 (X=5)
>
> is there any function for this? i have looked in several packages
> (vegan, labdsv etc.) because I am working with species by site tables,
> but without success. perhaps I looked for the wrong terms (rank matrix
> etc.)
>
> thank you for your help
>
> regards,
> Jens
>

-- 
==================================================================
Naira Naouar 

Tel:+32 (0)9 331 38 63
VIB Department of Plant Systems Biology, Ghent University
Technologiepark 927, 9052 Gent, BELGIUM
nanao@psb.ugent.be                         http://www.psb.ugent.be

______________________________________________
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 Mon 19 May 2008 - 12:57:50 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 Mon 19 May 2008 - 14:30:41 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