Skip to content
Prev 156187 / 398502 Next

How to find the index

On 16-Sep-08, at 8:04 AM, Peng Jiang wrote:

            
I use this function provided in the old "Blue Book".

sort.mat <-
function(mat1, col1)
{
	mat1[sort.list(mat1[, col1]),  ]
}

where "mat1" is the matrix to be sorted (in your case a n x 2 matrix  
of your vector and an index vector), and
"col1" is the column to be sorted on.

HTH
Don McKenzie, Research Ecologist
Pacific WIldland Fire Sciences Lab
US Forest Service

Affiliate Professor
College of Forest Resources
CSES Climate Impacts Group
University of Washington

desk: 206-732-7824
cell: 206-321-5966
dmck at u.washington.edu
donaldmckenzie at fs.fed.us