在启动时加载 .Rprofile [英] Getting .Rprofile to Load at Startup

查看:52
本文介绍了在启动时加载 .Rprofile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个全局 ~/.Rprofile 文件和另一个 .Rprofile 文件位于我的项目的当前工作目录中,两者都有以下内容:

I have a global ~/.Rprofile file and another .Rprofile file located in my project's current working directory and both of the have the following contents:

.First() <- function() {
options(rstudio.markdownToHTML = 
  function(inputFile, outputFile) {      
    system(paste("pandoc", shQuote(inputFile), "-s --webtex -o", shQuote(outputFile)))
  }
)  
}

不幸的是,当我打开 RStudio 应用程序时,它们似乎都没有工作.我想要做的目的是让Knit HTML"按钮呈现 Markdown 文件,该文件具有内联 LaTeX,使用 webtex 作为 LaTeX 渲染器通过 Pandoc 进行处理.

Unfortunately, when I open the RStudio app neither of them appear to be working. The aim of what I'm trying to do is to make the "Knit HTML" button render the Markdown file, which has inline LaTeX, process through Pandoc using webtex as the LaTeX renderer.

有谁知道我如何检查我的 .Rprofile 文件是否在启动时加载?

Does anyone know how I check whether my .Rprofile files are loading at startup?

感谢您的帮助!

POST ANSWER EDIT(在 Josh 的回答之后):为清楚起见,我的工作项目的 .Rprofile 文件(有效)现在读取如下:

POST ANSWER EDIT (after Josh's answer): For clarity, my working project's .Rprofile file (which works) now reads as such:

options(rstudio.markdownHTML =
  function(inputFile, outputFile) {
    system(paste("pandoc", shQuote(inputFie), "-s --webtex -o", shQuote(outputFile)))
  }
)
 \\ you will need to end with a blank carriage return underneath

推荐答案

R 文档应该有助于了解如何处理 .Rprofiles.在控制台执行以下操作:

The R docs should help to see how to deal with .Rprofiles. Execute the following at the console:

> ?Startup

这个的相关部分表示你需要将你的项目.Rprofile放在启动项目时将加载的初始工作目录中.因此,如果您的项目是 ~/foo/foobar.Rproj,那么您的配置文件应该是 ~/foo/.Rprofile 并确保在启动时,初始工作目录是 ~/foo/.您可以在 RStudio 控制台窗格顶部的标题栏中看到这一点.

The relevant portion of this indicates that you need to put your project .Rprofile in the initial working directory that will be loaded when starting the project. Thus if your project is ~/foo/foobar.Rproj, then you should have your profile be ~/foo/.Rprofile and make sure that when starting up, the initial working directory is ~/foo/. You can see this in the title bar at the top of the console pane in RStudio.

另外为了确认正确的 .Rprofile 确实被加载,我会亲自进行测试以查看哪个(如果有)配置文件被拾取.例如,包括:

Also to confirm that the correct .Rprofile is actually being loaded, I would personally put in a test to see which (if any) profile is being picked up. For example, include:

print("This is the Rprofile inside the foo project!")

这里是另一个关于让它工作的例子:

Here is another example about getting this to work:

http://support.rstudio.org/help/discussions/suggestions/1095-different-rprofile-for-a-project#comment_15690293

最后,如果在项目中加载了正确的 .Rprofile,那么您的代码一定有问题.看起来您是从我们的 docs 中获得的,所以如果您加载了配置文件,并且仍有问题,请告诉我们.您可以在我们的支持主题上发表新讨论.

Finally, if the correct .Rprofile is being loaded inside the project, then there must be something wrong with your code. Looks like you got this from our docs though, so if you get the profile loaded, and continue to have problems, please let us know. You can post a new discussion on our support thread.

乔希

产品经理 - RStudio

Product Manager - RStudio

这篇关于在启动时加载 .Rprofile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆