R语言-排序

1 > c
2 [1] 1 2 3 4 5 6 1 3
3 > sort(c)
4 [1] 1 1 2 3 3 4 5 6
5 > order(c)
6 [1] 1 7 2 3 8 4 5 6

sort与order都是对向量排序,sort返回的是向量排序后的值(小-大),order是对向量排序,然后返回向量的索引(也就是原先所在的第几个位置,默认是1:n的正整数)。

posted @ 2016-10-04 14:18  BelFuture  阅读(505)  评论(0编辑  收藏  举报
The horizon of life is broadened chiefly by the enlargement of the heart.