In R and RStudio, I think I have messed around with the .Rprofile
file a few times, and I currently am loading up an old version of it upon startup of R or RStudio, is there a way that I can quickly find the location of the file that is generating the default options?
Thanks
Rprofile is located in the users' home directory ( ~/. Rprofile on MacOS/Linux). This . Rprofile is run whenever you start up R.
When you start R, it will by default source a . Rprofile file if it exists. This allows you to automatically tweak your R settings to meet your everyday needs.
Renviron file in your Home Directory. Find your Home directory by clicking on the Home button in the Files pane of RStudio. Then, simply create a new text file (File > New File > Text File) and save it as . Renviron .
Like @Gsee suggested, ?Startup
has all you need. Note that there isn't just the user profile file, but also a site profile file you could have messed with. And that both files can be found in multiple locations.
You could run the following to list existing files on your system among those listed on the page:
candidates <- c( Sys.getenv("R_PROFILE"), file.path(Sys.getenv("R_HOME"), "etc", "Rprofile.site"), Sys.getenv("R_PROFILE_USER"), file.path(getwd(), ".Rprofile") ) Filter(file.exists, candidates)
Note that it should be run on a fresh session, right after your started R, so that getwd()
will return the current directory at startup. There is also the tricky possibility that your profile files do modify the current directory at startup, in which case you would have to start a "no-profile" session (run R --no-site-file --no-init-file
) before running the code above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With