[R] Finding and changing .Rprofile

Marc Schwartz m@rc_@chw@rtz @end|ng |rom me@com
Sat Aug 18 00:17:57 CEST 2018


> On Aug 17, 2018, at 4:06 PM, philipsm using cpanel1.stormweb.net wrote:
> 
> I would like to change my .Rprofile file, but I cannot find it. I use a Mac Pro and RStudio. I believe the file is a hidden file and I have checked for it accordingly. I can not find it with a Spotlight search. It is not in my "default working directory". Is that the same thing as my "home directory"? I believe I can put a new .Rprofile file in any project directory, but that is not what I want to do. I want a .Rprofile file that will apply automatically whenever I start working on another project. Was one installed automatically when I installed R and RStudio many months ago and if so, where can I find it? If it was not installed automatically and I have to create my own, where should I put it?


Hi, 

As an FYI, there is a dedicated R list for macOS users:

  https://stat.ethz.ch/mailman/listinfo/r-sig-mac

which should be used for macOS specific questions vis-a-vis R.

The default .Rprofile is stored in your user home folder, which is /Users/YourUserName/.Rprofile or abbreviated as ~/.Rprofile.

As you note, because it is a hidden file, with a leading '.', Finder and Spotlight will not show it by default.

You can change that behavior relative to hidden files, by opening a Terminal and using the following command:

  defaults write com.apple.finder AppleShowAllFiles TRUE

then restart Finder, by using Alt-RightClick on the Finder icon in the dock and selecting Relaunch. You can reverse that behavior by changing the TRUE to FALSE in the above command.

If you don't want to make that global change, you can use the following command in a Terminal session:

  open -a Textedit ~/.Rprofile

That will bring up the Textedit editor application with the file loaded. You can then edit the file content and save it. 

Whichever way you edit the file, be sure to restart any R sessions you have running, so that future R sessions will pick up the changes.

Making the change to that file will generally affect all R sessions for your user profile.

I don't use RStudio, so it may have other relevant features, and they have their own support lists linked on their site.

Regards,

Marc Schwartz




More information about the R-help mailing list