简体   繁体   中英

how to fix special foreign characters in RStudio message (encoding)

I'm using R 3.2.2 and RStudio in Win 7. I installed Asian characters, but the default encode in most part of my computer should be UTF-8 (I don't know how to check this in RStudio).

The messages of RStudio often has special characters

> library(ggmap)
Loading required package: ggplot2
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  there is no package called 慠cpp?Error: package 慻gplot2?could not be loaded

How should I make this display correctly? Can somebody help please. Thanks!

It seems this is because RStudio is not a complete unicode program. Just found the solution here: http://daneix.blogspot.com/2014/08/r-studio-console.html

Briefly, run the following code every time you start up RStudio:

Sys.setlocale("LC_ALL","Chinese")

Also you can construct a .Rprofile in the default working directory of RStudio (you can find it in RStudio -> Global Options -> General), then it will be called automatically when starting up RStudio.

However, the disadvantage is that some output of R will be displayed in Chinese.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM