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

______________________________________________
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