How to check that R Profile is being run when R is started?



I am trying to add an option to an R Profile file so that when R is started the option is set automatically. In particular, I’m trying to change a blogdown option (through using options(blogdown.subdir = 'blog')).

I followed the steps in Section 1.4 of @yihui’s blogdown book to edit the file:


When I restart my R session and / or close and reopen R Studio, the R Profile file remains changed, but the option does not appear to have unless I run the options() line in the console. I then tried adding a few other things to my R Profile (i.e., message("Hello!") to test whether the file was run, but was curious if there is a more reliable or better way to check that the file is being run.


One idea: you could set a variable to the global environment in your .Rprofile script, then check for that variable’s existence. (Or if you don’t want to touch the global environment, you could set a value using options() and again check for existence.)


Do you also have a .Rprofile file under the current (project) directory? Did you read the last paragraph of Section 1.4?


If your option is not set but your .Rprofile is modified, it is possible that it is not the one that is run at startup as @yihui suggests.

To know more about startup process in R, you could see this great post on Rviews