When R starts (with default options), it loads the .Rprofile
and .Renviron
files in the working directory or user's home directory. In my case these files may be changed during the course of the R session (e.g. as packrat does). I was wondering if there is a way to ask R to simply refresh its .Renviron
having to quit and restart R?
For instance, in the case of .Rprofile
, it is sufficient to simply source(".Rprofile")
to reload the .Rprofile
from the working directory. Can something similar be managed for .Renviron
?
You can restart R by clicking on Session -> Restart R (top menu).
If you use RStudio, use the menu item Session > Restart R or the associated keyboard shortcut Ctrl+Shift+F10 (Windows and Linux) or Command+Shift+F10 (Mac OS).
7.3 Disabling startup files You can run R without any startup files by using the --vanilla argument when starting R. In RStudio you can do this by checking the option Project Options -> Disable . Rprofile execution on session start / resume .
These files are set for each version of R and should be located in R_HOME/etc/ . You can find R_HOME by running the command R.
Use readRenviron
Reference: http://stat.ethz.ch/R-manual/R-devel/library/base/html/readRenviron.html
Yes I remember getting stuck on Sys.getenv a while ago. and thanks to your question, it reminded me about packrat. Going to use it to distribute some code for a manuscript.
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