小编Shr*_*Tan的帖子

为什么R data.table不支持Windows上的非ASCII键

好吧,我已经在Github上提交了这个问题,但没有得到回复.data.table是一个伟大的R包,在日常工作中帮助我们很多.

但是,在版本1.9.6之后,如果列没有以UTF-8编码(R中的默认非ASCII字符编码取决于平台),它突然不支持Windows上的非ASCII键.

这很可能是一个错误(我会说一个大错误).我很惊讶,没有人关注这个,因为这个bug已经存在了将近2年,所以没有人抱怨.

我花了好几个小时试图解决这个问题,但都失败了.相关提交是https://github.com/Rdatatable/data.table/commit/03cd45f83fe41e4a6507b9b2e4f955c105979c8chttps://github.com/Rdatatable/data.table/commit/409d709380e865d014f21f17a254e0bbcf1e156d

他们实际上是在尝试将其他编码字符转换为UTF-8,然后对UTF-8中的所有字符进行排序和比较.似乎编码处理是正确的.但是,我确实怀疑这个bug被隐藏了.实施data.table真的很复杂,我问是否有人可以提供帮助,以便我们可以制定公关来解决这个问题.

非常感谢.

Minimal reproducible example

数据集

library(data.table)
## data.table 1.10.5 IN DEVELOPMENT built 2017-12-01 20:06:10 UTC
## The fastest way to learn (by data.table authors): https://www.datacamp.com/courses/data-analysis-the-data-table-way
##  Documentation: ?data.table, example(data.table) and browseVignettes("data.table")
##  Release notes, videos and slides: http://r-datatable.com
dt <- data.table(
  x = c("????????", "????", "????", "??????", "??????"),
  y = 1:5,
  key = "x"
)
Run Code Online (Sandbox Code Playgroud)

如果编码是本机的,则会失败(返回NA)

dt[]
##                   x y
## 1: ???????? 1 …
Run Code Online (Sandbox Code Playgroud)

encoding r data.table

8
推荐指数
1
解决办法
155
查看次数

标签 统计

data.table ×1

encoding ×1

r ×1