Generating inverse permutation

后端 未结 2 600
执念已碎
执念已碎 2021-01-11 11:28

Suppose we are given a vector foo and we have to temporarily permute it (sort or re-order it), compute some vector bar on the base

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-11 11:36

    To recover the original order, use order(o):

    > (foo[o]*2)[order(o)]
    [1]  2 14  6 10  4
    

提交回复
热议问题