首页 > 解决方案 > 按 ASCII 顺序排列 R 中的列

问题描述

我想按 ASCII 顺序排列我的列名,这意味着所有 LARGE 字母都在 small letters 之前

例如,我制作了以下代码:

test_ordered <- test[ , sort(names(test))]

这确实按名称对列名进行排序,如下所示:

A B d F g H 

但是,我想在这里实现的是:

A B F H d g

这是sorted()Python 的标准工作方式:

df_curr = df_curr[sorted(df_curr)]

提前致谢!

标签: rdataframesortingcolumnsorting

解决方案


推荐阅读