I need to create a data.table, and some column names need to have some unicode symbols for consistence reason(I better to make it match another source which have these names).
In some locale there is no problem, but some user will met problem. Turned out my code will not work in certain locale.
Sys.setlocale("LC_CTYPE", "English_United States.1252")
> df <- data.frame("\u0394AICc" = 2)
Warning message:
unable to translate '<U+0394>AICc' to native encoding
> dt <- data.table(mtcars)
> dt[, "\u0394AICc" := "test"]
> dt
...
Warning message:
In do.call("cbind", lapply(x, function(col, ...) { :
unable to translate '<U+0394>AICc' to native encoding
# interestingly, the string can be printed normally in console
# just it will have problem as a data.frame column name.
> cat("\u0394AICc")
ΔAICc
I searched around and most information I found are about file or string encoding, not really data.frame column names.
There was an issue in data.table for this, it also depend on R/OS/locale. Given data.frame cannot handle it either, I think it's not a data.table problem.
All the problem will gone with some other locale, so I'm hoping there is a way to fix this and don't have to remove all the unicode symbols.