问题描述
我正在尝试在 ~/.Rprofile 脚本中为 blogdown 包设置一些全局选项,但它们没有被获取.下面是 .Rprofile 脚本的样子:
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")
我还尝试通过在项目的工作目录中创建 .Rprofile 脚本来设置项目级别的选项.但这也没有来源.
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.
我从 RStudio 中重新启动了 R 会话,也重新启动了 RStudio 并最终重新启动了我的计算机.没有运气.
I have restarted the R session from within RStudio and have also restarted RStudio and finally restarted my computer. No luck.
即使我只使用基础 R(而不是 R Studio),选项也没有设置.
Even when I just use base R (and not R Studio), the options are not set.
如果我手动获取 .Rprofile (source("~/.Rprofile")
),那么这些选项将生效,这意味着 RStudio 的 blogdown 的新帖子"插件将显示正确的作者姓名 (Maryam Khezrzadeh),默认情况下会选择 .Rmd 文件.
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.
我使用的是 MacOS Sierra(版本 10.12.6),以下是相关环境变量的值:
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!
推荐答案
解决方案是确保在 .Rprofile 脚本的末尾有一个新行.感谢Yihui Xie 的回答.
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.
查看这篇博文,了解什么是.Rprofile的麻烦,如果它没有尾随换行符.
See this blog post to find out what is the trouble of .Rprofile if it doesn't have a trailing newline.
这篇关于.Rprofile 没有来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!