Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Rprofile not sourced

I am trying to set some global options for blogdown package in ~/.Rprofile script but they are not being sourced. Here's how the .Rprofile script looks like:

options(blogdown.ext = ".Rmd", blogdown.author = "Maryam Khezrzadeh")

I have also tried setting the options at the project level by creating an .Rprofile script in my project's working directory. but that doesn't get sourced either.

I have restarted the R session from within RStudio and have also restarted RStudio and finally restarted my computer. No luck.

Even when I just use base R (and not R Studio), the options are not set.

if I manually source .Rprofile (source("~/.Rprofile")), then the options will take effect, meaning that the blogdown's "New Post" addin for RStudio will show the right author name (Maryam Khezrzadeh) and would choose .Rmd files by default.

I'm on a MacOS Sierra (version 10.12.6) and here are the values of relevant environment variables:

R_HOME = "/Library/Frameworks/R.framework/Resources"
R_PROFILE_USER = ""
R_PROFILE = ""

Any advice on how to go about troubleshooting this is appreciated. Thank you so much for your help!

like image 477
mkhezr Avatar asked Jun 04 '18 17:06

mkhezr


People also ask

Where is .rprofile file?

Rprofile files live in the base of the user's home directory, and project-level . Rprofile files live in the base of the project directory. R will source only one . Rprofile file.

Where is. Rprofile on windows 10?

You can customize the R environment through a site initialization file or a directory initialization file. R will always source the Rprofile. site file first. On Windows, the file is in the C:\Program Files\R\R-n.

Which file contains settings that R uses by default?

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.


1 Answers

The solution is to make sure that there is a trailing new line at the end of .Rprofile script. Thanks to Yihui Xie for the answer.

See this blog post to find out what is the trouble of .Rprofile if it doesn't have a trailing newline.

like image 66
mkhezr Avatar answered Sep 19 '22 20:09

mkhezr