Hi all,

I have matrix, A. I want to sort the elements in each column in a ascending
order and output the index number their position. For example

A = 

          [,1]     [,2]      [,3]       [,4]
[1,] 135.87060 97.55820 121.07722 171.625495
[2,]  70.19811 36.64529  50.13501   6.319125
[3,]  26.86293 24.22025  43.42826  26.952587
[4,]   1.88864 54.97618  12.50913 103.958836

I want the output, B, to be

B = 

     [,1] [,2] [,3] [,4]
[1,]    4    4    4    4
[2,]    3    2    3    1
[3,]    2    1    2    2
[4,]    1    3    1    3

I tried "apply(test,1,order)", but it did not work. Could anybody please
help? Thank you very much.

Wendy


--
View this message in context: 
http://r.789695.n4.nabble.com/get-the-sorted-index-of-elements-within-a-column-tp3896606p3896606.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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