R语言 order函数

2022-11-02  本文已影响0人  经世致用bio

一 函数用途
对当前向量进行升序或降序处理,返回排序结果的值在原有向量中的位置,默认为升序,decreasing = T参数的使用可使其降序排列。
二 函数语法

order(...,na.last = TRUE,decreasing = FALSE,
             method = c("auto","shell","radix"))

三 示例

a <- c(78,57,89,93,42)
 a
[1] 78 57 89 93 42
b <- order(a)
 b
[1] 5 2 1 3 4
c <- order(a,decreasing = T)
c
[1] 4 3 1 2 5
d <- order(a,decreasing = T)[1:3]
d
[1] 4 3 1
上一篇 下一篇

猜你喜欢

热点阅读