How to order data set in R

This question already has an answer here:

  • How to sort a dataframe by multiple column(s)? 16 answers

  • You can use with or $ , [ , ie

    dataset[with(dataset, order(-COL1)),] 
    

    Or

    dataset[order(-dataset$COL1),]
    

    Or

    dataset[order(-dataset['COL1']),]
    

    Or

    library(data.table)
    setorder(setDT(dataset), -COL1)
    
    链接地址: http://www.djcxy.com/p/70856.html

    上一篇: 将子数据组中的R数据帧中的数据进行排序

    下一篇: 如何订购R中的数据集