我的数据框如下所示
GR1-text GR11-text GR12-text GR2-text
A 1 1 0 0
B 1 0 1 1
我想将数据框排序为:
GR1-text GR2-text GR11-text GR12-test
A 1 0 1 0
B 1 1 0 1
我尝试了following没有效果
test <- df[ , order(names(df))]
我也发现了这个custom function,但我看不到让它发挥作用。
答案 0 :(得分:0)
尝试使用order(readr::parse_number(names(df)))
。