0

R (RGui/RStudio) shows an encoding issue. Here is an example:

my <- "≠"
my
as.data.frame(my)

The result is:

> my <- "≠"
> my
[1] "≠"
> as.data.frame(my)
        my
1 <U+2260>

Any ideas, why I get different results?

Some information about local configuration:

> Sys.getlocale()
[1] "LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252"
  • I cannot confirm; for me, `as.data.frame(my)` returns `1 ≠` with one column `my` (both in RStudio and a vanilla R terminal). U+2260 is unicode for ≠, suggesting there might be something weird with displaying unicode characters on your machine. What does `locale()` say? – Maurits Evers Sep 05 '22 at 09:13
  • Thanks @mauritsevers. I added some system information. – Knut Wenzig Sep 05 '22 at 09:33
  • 1
    Also can't reproduce with `LC_COLLATE=French_France.utf8;LC_CTYPE=French_France.utf8;LC_MONETARY=French_France.utf8;LC_NUMERIC=C;LC_TIME=French_France.utf8` – Waldi Sep 05 '22 at 09:39
  • 1
    @KnutWenzig My guess is this has to do with your Windows-1252 encoding (which does not include all unicode characters). I don't have a Windows machine so can't test, but I suggest [changing your encoding to UTF-8](https://support.rstudio.com/hc/en-us/articles/200532197-Character-Encoding-in-the-RStudio-IDE) (which should've been the default AFAIK). – Maurits Evers Sep 05 '22 at 10:15
  • Also relevant (a dupe?) is [this post](https://stackoverflow.com/questions/46728047/r-rstudio-console-encoding-windows). – Maurits Evers Sep 05 '22 at 10:17

0 Answers0