Operating System: Windows 10 Home 64-bit
R version: 4.0.3
RStudio version: 1.4.1106
Directory: C:\Users\xxx\rmarkdownfile\test.Rmd (where xxx contains your username)
This is my first time to ask you a question.
As the title suggests, I am creating an Rmarkdown file in RStudio, but the message is displayed in a text format.
For example, to load the package "socviz", perform the following chunks:
library(socviz)
The following message appears:
p b P [Wesocviz f f o [ [4.0.5 � R ̉ / ܂ � p < � > � oc � v � � � . � � � � 5 . � � 0 4 b s e � � � � � [ W ő
Perhaps the message is
"Warning Message: Package 'socviz' was created under R in version 4.0.5"
It seems that the load itself has been completed, but I would like to solve the problem because it would be inconvenient if I could not read the message.
Similar garbled characters occur not only in socviz but also in libraries such as MASS and tidyverse.
Neither the pass nor the document contains two-byte characters including Japanese.
If you run directly from the console or type from RScripts, Japanese will be displayed without any problems.
I heard that garbled characters occur when I use folders under Google Drive or OneDrive management as a working directory, so I put the working directory in a local location and stopped synchronizing before running, but it doesn't change.
Tools > Global Options > code > saving > Default text encoding is set to UTF-8.
I tried UTF-9, cp932, and SHIFT-JIS from File>Reopen with Encoding, and all of them are experiencing the same symptom.
At the moment, Windows cannot combine Japaneseization of messages with anything else. UTF-8 is assumed, but this is what happens because Windows Japanese locale does not use UTF-8 . You have to create Linux virtual environments such as WSL or Docker, or work in cloud environments (UTF-8 enabled R is still being developed).
Sys.setlocale ("LC_ALL", 'Japanese_Japan.932')
As a result, I think the pattern of using the same CP932 encoding as the OS and displaying the message in English is the most difficult.
If the locale is set to "C", will it be impossible to handle two-byte characters?It looks like this, so
That's right. "C" means to stop dealing with multi-byte characters (although the exact definition is different). This increases inconvenience in other situations.
Tools > Global Options > code > saving > Default text encoding is set to UTF-8.
I tried UTF-9, cp932, and SHIFT-JIS from File>Reopen with Encoding, and all of them are experiencing the same symptom.
This is an encoding of a text file (CSV, R file, etc.) to be loaded, so it has nothing to do with this issue. What is involved is a change in the encoding of the system.
Characters get garbled when Google Drive or OneDrive-managed folders are in the working directory
In the Japanese environment, Japanese is often included in the paths pointing to those folders, so it is easy to cause problems, but I don't think there are many cases where characters are garbled.
I've solved it myself.
Set.locale("LC_ALL", "C") now displays the error message correctly.However, if the locale is set to "C", can't you handle two-byte characters?So if you really need to include Japanese, you may need to think of another way......
© 2024 OneMinuteCode. All rights reserved.