-1
我有一个数据帧,Game
的一列,由以下组成:(无引号)排序中的R的字符向量包含的字母和数字
"Euro Round 1 West"
"Euro Round 2 Broncos"
"Euro Round 3 Tigers"
"Euro Round 4 Tigers"
"Euro Round 5 Broncos"
"Euro Round 6 West"
"Premier12 Round 1 Eagles"
"Premier12 Round 10 Mac"
"Premier12 Round 11 Cats"
"Premier12 Round 12 Owls"
"Premier12 Round 13 Devils"
"Premier12 Round 14 Zebras"
"Premier12 Round 15 Cats"
"Premier12 Round 16 Zebras"
"Premier12 Round 17 Owls"
"Premier12 Round 2 Eagles"
...
我想数据帧是按此专栏排序。
首先按字母顺序“欧元”或“Premier12”,然后数值由“回合_”
然而,你可以看到的第二部分的上方,即数值顺序是像这样:1,10,11,12 ,13,14,15,16,17,2,3,4,...
我该如何解决这个问题?
而且,有可能有这个也改变字符订购并在括号中添加像这样:
"West (Euro Round 1)"
"Broncos (Euro Round 2)"
"Tigers (Euro Round 3)"
"Tigers (Euro Round 4)"
"Broncos (Euro Round 5)"
"West (Euro Round 6)"
"Eagles (Premier12 Round 1)"
"Eagles (Premier12 Round 2)"
"Devils (Premier12 Round 3)"
...
要不然:
"West, Euro Round 1"
"Broncos, Euro Round 2"
"Tigers, Euro Round 3"
"Tigers, Euro Round 4"
"Broncos, Euro Round 5"
"West, Euro Round 6"
"Eagles, Premier12 Round 1"
"Eagles, Premier12 Round 2"
"Devils, Premier12 Round 3"
...
感谢
我已阅读How to sort a character vector where elements contain letters and numbers in R?,这与我的问题类似,但我无法弄清楚