I am not sure if this is the best place for this, but I really hope someone can help me in the right direction to solve this. I have a problem with the display of unicode characters '≥' and '≤' in the output: R changes these characters to a '=' sign. I happens under windows but not under linux.
I came across this problem after reading an excel file with readxl::readr(), but the following minimal reproducible example gives the same error:
a <- data.frame(x= "≥",y="≤")
a
Output:
x y
= =
Expected output:
x y
≥ ≤
Session info:
R version 4.0.2 (2020-06-22) (EDIT: same happens after updating to R 4.0.3)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Rstudio version 1.4.1087
LC_COLLATE=English_United Kingdom.1252
Same happens on a different computer with the same R version (4.0.2) but with a different locale:
LC_COLLATE=Dutch_Netherlands.1252
But it does not happen on a Linux server with an older R version:
R version 3.6.0 (2019-04-26)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Red Hat Cloud Infrastructure
LC_CTYPE=en_US.UTF-8
In the last Linux environment I get the expected result, but I also need it to work on my personal computer.
Is this because of the R version? Or because the locale is not set properly? Or it just does not work under windows? Any help is appreciated!
Thanks for trying this out and replying. I am wondering if it is operating system dependent and only occurs in windows; I saw you are using macOS, with a different locale (en_US.UTF-8).
Thanks for trying. So it might be a Windows problem. It also occurs in plane R (outside Rstudio). My Rstudio is standard set to UTF-8 (if it matters; I checked it).
I just came across another question with this similar problem, but no solution posted, from 2019:
My goal is to print this greater than or equal sign in a knitr::kable() table , using R/Rstudio my own windows computer; I need it to work with HTML and pdf output.
For future reference: I started a topic on Stackoverflow, also showing some workarounds for specific cases that work for my data (although the workaround are a bit inconvenient).
I think that until UTF-8 in R under windows is fully supported (see here), there are no general solutions under windows. I'd be happy if someone proves me wrong on this though.