Turkish Language Encoding Problem in R Studio - r

I am using R Studio for creating plots for economic variables. But in our language when you don't use our specific letters as "ğ,ş,ı,ü,ç" the word means different. And even sometimes it means swearing. I can't create graphs with this letters. I tried to use this command;
Sys.setlocale(category = "LC_ALL", locale = "Turkish")
The output is
OS reports request to set locale to "Turkish" cannot be honored[1] ""
How can i solve this problem? Any idea?

If you have the same problem and your system is Mac. First open terminal and then copy this code:
defaults write org.R-project.R force.LANG en_US.UTF-8
paste and run. I solved. I hope it works for your system, too.

Related

RStudio does not read non-English characters in paths

I want to list files and folders containing Japanese characters in my working directory with list.files(), but when I tried this, it does not show the proper files names.
For example, the "test" direcotry has folders "test1", "test2", "テスト3", and running list.files() gives unreadable characters for the one with Japanese characters like this.
> getwd()
[1] "C:/Users/10040153/Documents/test"
> list.files()
[1] "繝<86>繧ケ繝<88>3" "test1" "test2"
What I tried
Set "Default text encoding" to UTR-8
Changed locale setting to Japanese with sys.setlocale(locale = "Japanese"), which returned [1]"LC_COLLATE=Japanese_Japan.932;LC_CTYPE=Japanese_Japan.932;LC_MONETARY=Japanese_Japan.932;LC_NUMERIC=C;LC_TIME=Japanese_Japan.932"
Reinstalled R and RStudio
Rebooted the computer
None of these didn' help.
I doubt this is an issue with RStudio, not R program, because I see no problems with running the same code above in R. Does anybody have an idea?
System environment
Windows 10 x64
RStudio
R version 4.1.2 (2021-11-01)
Update
`Encoding<-`(list.files(), "UTF-8") solved the problem.
> `Encoding<-`(list.files(), "UTF-8")
[1] "テスト3" "test1" "test2"
I know this has something do with encoding, but how can I make it work in global environemt?
This is a known bug in RStudio; see https://github.com/rstudio/rstudio/issues/10451. If you're willing to try a fix, we have one in the dailies as of last week:
https://dailies.rstudio.com/

How to set encoding for Jupyter Notebook in R?

Simple question, but I can't find an answer for R. I found it for Python, but I didn't test it.
When I put to input line of the notebook: setOption(encoding = "Windows-1250") nothing exactly happens. I know (from Python review) I should save it to environment somehow, but how? I created Jupyter Notebook (my first time) from Anaconda by launching button, previously installed all dependencies. Everything's ok (Windows 7).
It's a problem with plotting my locale characters in plots. And maybe, I should encode my characters directly to unicode notation? Like: u003d? But it's time consuming. Any suggestions?

Converting accents to ASCII in R

I'm trying to convert special characters to ASCII in R. I tried using Hadley's advice in this question:
stringi::stri_trans_general('Jos\xe9', 'latin-ascii')
But I get "Jos�". I'm using stringi v1.1.1.
I'm running a Mac. My friends who are running Windows machines seem to get the desired result of "Jose".
Any idea what is going on?
The default encoding on Windows is different from the typical default encoding on other operating systems (UTF-8). x ='Jos\xe9' means something in
Latin1, but not in UTF-8. So, on Linux or OS X you need to tell R what the encoding is:
x ='Jos\xe9'
Encoding(x) <- 'latin1'
stri_trans_general(x, 'Latin-ASCII')

The wrong symbols inplace of Cyrillic in Rpres file (RStudio)

I have a trouble - the presentation compiled in RStudio can't make the correct output. Instead of cyrillic symbols(Ukrainian/Russian) I have got smth from ASCII list (�).
Could you help me with cyrillic?
so far I have not found a clear hints how to remove this trouble.
PC:
win7 bit
RAM 8Gb
R 3.3.0 64bit
Rstudio - Version 0.99.486
Try "save with encoding" (UTF-8 or whatever is the right encoding).
You can also change the default encoding in Rstudio from Tools --> Global options --> Default text encoding.

Student's computer using Chinese locale, inherited from Windows 7

A student in my chemometrics course installed R on Windows 7. Apparently, R picked up something from his computer automatically, so R operates in Chinese (yes, he is Chinese). He's trying to change it back to English (important because scripts must be turned into me in English!).
He sent me the 1st screen shot below. The 2nd screen shot shows my suggestion to change the locale. R reports (in Chinese) that it can't change it.
Any suggestions? Thanks.
Check sessionInfo()
try:
Sys.setlocale("LC_ALL", "English")
Run R with the added command line parameter LANGUAGE=en OR delete the share/locale folder:
http://notepad.patheticcockroach.com/412/how-to-change-language-in-r/
Windows likely has a way to set the locale information passed to a program, though I don't know how offhand. You could try setting it there, outside of R.

Resources