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?

Community
  • 1
  • 1
johnsonzhj
  • 517
  • 1
  • 5
  • 23
  • 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 https://csgillespie.github.io/efficientR/3-3-r-startup.html#r-startup – johnsonzhj Apr 24 '17 at 11:38
  • By the way, `file.path` has no effect in your code. – Konrad Rudolph Apr 24 '17 at 12:15
  • yes, you are right, I have fixed it. – johnsonzhj Apr 24 '17 at 12:19

1 Answers1

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.

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214