且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

基于作为输入传递的多列的订单

更新时间:2023-02-02 22:24:05

使用 do.call :

data[do.call("order", data[sortCols]), ]

其中 data 是数据框,而 sortCols 是列名的字符向量.

where data is a data frame and sortCols is a character vector of column names.

还可以查看doBy软件包中的 orderBy .

Also have a look at orderBy in the doBy package.