[心得] sort CharacterVector
[關鍵字]: R, string, sort
[重點摘要]:
今天踩到地雷了。
我寫了一個script,在Rstudio和console下的行為卻不同,經過一兩天的debug才發現:
```r
a <- c(letters, LETTERS) # 英文的大小寫字母
sort(a)
```
的結果會和系統環境有關!!
在sort的說明文件中有:
```
The sort order for character vectors will depend on the collating sequence of the locale in use: see Comparison. The sort order for factors is the order of their levels (which is particularly appropriate for ordered factors).
```
例如:http://rpubs.com/wush978/sorting
FYI
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.135.56.60
→
01/09 13:16, , 1F
01/09 13:16, 1F
→
01/09 13:17, , 2F
01/09 13:17, 2F
→
01/09 13:25, , 3F
01/09 13:25, 3F
R_Language 近期熱門文章
PTT數位生活區 即時熱門文章