美文网首页
R语言 order函数

R语言 order函数

作者: 经世致用bio | 来源:发表于2022-11-02 16:57 被阅读0次

一 函数用途
对当前向量进行升序或降序处理,返回排序结果的值在原有向量中的位置,默认为升序,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

相关文章

网友评论

      本文标题:R语言 order函数

      本文链接:https://www.haomeiwen.com/subject/opddtdtx.html