I'm on Windows 8.1 (en) and my R console won't understand Russian characters and produce smth like this (both in console and if I run R file)
> x <- "Привет"
> print(x)
[1] "Ïðèâåò"
I know that this can happen if you save CP1251 as CP1252. I set up all R options to UTF-8, and source files as UTF-8, but this doesn't help. I also set up sysLocale to Russian as here, but got nothing. Some advise from RStudio faq didn't help either. The strange thing though, that ggplot2 works absolutely fine
dt <- as.data.frame(cbind(x = c("Один", "Два"), y = c(3, 5)))
ggplot(dt, aes(x=x, y=y))+geom_bar() + xlab("Счет")
This is my sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=Russian_Russia.1251 LC_CTYPE=Russian_Russia.1251 LC_MONETARY=Russian_Russia.1251 LC_NUMERIC=C
[5] LC_TIME=Russian_Russia.1251
attached base packages:
[1] stats graphics grDevices utils datasets methods base
I use last version of RStudio, but dev version also would not help
UPDATE:
> Encoding(x)
[1] "unknown"
> getOption("encoding")
[1] "native.enc"
If I use RGUI, after Sys.setlocale("LC_ALL", "Russian")
it will allow to
> print(x)
[1] "Привет"
I also checked in the Russian version of Windows - Rstudio works ok
Sys.setlocale("LC_ALL", "Russian")
Did not work for me.
Sys.setlocale("LC_CTYPE", "en_RU.UTF-8")
Did the job! now utf files with Cyrillic characters display properly in the R/RStudio Console. But that only seems to work until R or RStudio is restarted.
also, running
defaults write org.R-project.R force.LANG en_US.UTF-8
in OS X Terminal solves all my problems with non-Latin characters for good.
Sys.setlocale("LC_ALL", "Russian_Russia.1252")
fixed the problem in my case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With