9

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!

mkhezr
  • 564
  • 5
  • 10
  • What exactly are you trying to accomplish with this Rprofile file? What OS are you using? What are you doing to "test" if it worked? Does it work if you don't use Rstudio and just use base R? – MrFlick Jun 04 '18 at 18:02
  • I'm trying to set global options for blogdown pckage. I am updating the question to include these details. – mkhezr Jun 04 '18 at 18:05
  • 2
    You probably ran into this issue: https://yihui.name/en/2018/04/rprofile-trailing-newline/ – Yihui Xie Jun 05 '18 at 03:05
  • 1
    No problem! Since this has confused several users, I just added a note in the blogdown book: https://bookdown.org/yihui/blogdown/global-options.html – Yihui Xie Jun 05 '18 at 05:06

1 Answers1

14

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.

mkhezr
  • 564
  • 5
  • 10