How to find the index
On 9/16/2008 11:04 AM, Peng Jiang wrote:
Dear R experts, i have a vector z , i have to do something after z is sorted. how can i find the original index, i.e., before sorting, of a certain element in the sorted vector .
You can't. Sorting loses information, and the original index is part of the information that is lost. What you should do is use order() instead of sort(). x[order(x)] is the same as sort(x), but no information is lost. Duncan Murdoch