1

Under Mac OSX, for the general default, normally I start the terminal and use ls -al to check the availability of the .bash_profile and then use nano .bash_profile to add the necessary global default into it. But for R and Rstudio, if I want to set the global default for the input of the Chinese character with command Sys.setlocale(category = "LC_ALL", locale = "zh_cn.utf-8"). I use the following command to get the R_HOME

  R.home()

[1] "/Library/Frameworks/R.framework/Resources"

Then I copy the command Sys.setlocale(category = "LC_ALL", locale = "zh_cn.utf-8") into the newly created file named either .Rprofile or "Rprofile.site in the directory "/Library/Frameworks/R.framework/Resources/etc", but it seems not work for me, what's wrong for my steps? There is a close anwer to my question locate the ".Rprofile" file generating default options What's the difference between .Rprofile and Rprofile.site?

3
  • I guess I know the answer, it's because I forget to press enter after the typing of Sys.setlocale(category = "LC_ALL", locale = "zh_cn.utf-8"). the following link offers a good explanation for this csgillespie.github.io/efficientR/3-3-r-startup.html#r-startup
    – johnsonzhj
    Commented Apr 24, 2017 at 11:38
  • By the way, file.path has no effect in your code. Commented Apr 24, 2017 at 12:15
  • yes, you are right, I have fixed it.
    – johnsonzhj
    Commented Apr 24, 2017 at 12:19

1 Answer 1

1

Your question is a bit unclear but it seems that you’re asking for an equivalent to the configuration file ~/.bash_profile. That would be ~/.Rprofile. For more information, read the documentation on “Initialization at Start of an R Session”. This also answers your question “What's the difference between .Rprofile and Rprofile.site?”:

$R_HOME/etc/Rprofile.site is the site file, whereas [~/].Rprofile is the user file.

4
  • so if I want to add .Rprofile under etc instead of under directory ~/, I need to create a folder named Rprofile.site first?
    – johnsonzhj
    Commented Apr 24, 2017 at 12:17
  • @johnsonzhj Not a folder, a file, called .Rprofile.site. However, I’d generally (= always, except when explicitly targeting multiple users) prefer a user configuration over a site configuration. Commented Apr 24, 2017 at 12:21
  • Ic, so as a single user, what I need to do is just to create a user file .Rprofile rather than site file Rprofile.site?
    – johnsonzhj
    Commented Apr 24, 2017 at 12:28
  • @johnsonzhj Yes. Commented Apr 24, 2017 at 12:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.