简体   繁体   English

RStudio R演示文稿预览错误

[英]RStudio R Presentation Preview Error

I am trying to create an R Presentation in RStudio (File > New File > R Presentation). 我正在尝试在RStudio中创建一个R演示文稿(文件>新文件> R演示文稿)。 But when I try to create one with my working directory set to anything other than my default, I receive an error when it tries to preview. 但是,当我尝试使用工作目录设置为默认目录以外的其他目录创建目录时,尝试预览时会收到错误消息。

The error displays in the preview panel just beneath the title where the author and date should be, and it says "Error in readLines(if (is.character(input2)) { : cannot open the connection" . There are also no other slides that can be displayed even though there should be four from the default template. 该错误显示在预览面板中的作者和日期应位于标题的正下方,并显示"Error in readLines(if (is.character(input2)) { : cannot open the connection" 。)也没有其他幻灯片。即使默认模板中应该有四个,也可以显示。

I've searched all over but I haven't been able to find anyone with this issue. 我搜索了所有内容,但找不到任何与此问题有关的人。 Anyone have an idea what might be causing this? 有人知道这可能是什么原因吗?

I'm running: 我在跑:

  • Windows 7 Professional Windows 7专业版
  • RStudio v0.99.903 RStudio v0.99.903

I completely reinstalled all of my R programs (R, Rtools, RStudio), and started from a blank slate. 我完全重新安装了所有R程序(R,Rtools,RStudio),并且从空白开始。 I can now create a presentation in a non-default working directory. 现在,我可以在非默认工作目录中创建演示文稿。 As rawr stated, it was probably being caused because of some underlying path issue with the file being created. 如rawr所述,这可能是由于所创建文件的某些基本路径问题引起的。

I guess, reinstalling is not necessary. 我想,没有必要重新安装。 I found that the error is most likely related to setting a working directory in .Rprofile or related files via setwd() . 我发现该错误最有可能与通过setwd()在.Rprofile或相关文件中设置工作目录有关。

When I changed the critical line in my .Rprofile to 当我将.Rprofile中的关键行更改为

if(interactive()) setwd(<my preferred working directory>)

it worked. 有效。

I think the .Rprofile file influences the R processes needed for creating the presentation in the background, too. 我认为.Rprofile文件也会影响在后台创建演示文稿所需的R进程。 If these processes are always set to your standard working directory, they cannot find the relevant files there. 如果这些进程始终设置为您的标准工作目录,则它们无法在其中找到相关文件。 That also explains why it works when you put the presentation into your standard working directory. 这也解释了为什么在将演示文稿放入标准工作目录中时它可以工作。

EDIT: The line above works because interactive() is FALSE for these background processes I was talking about. 编辑:上面的行之所以有效,是因为针对我正在谈论的这些后台进程, interactive()是错误的。 So, for those, the setwd() is not called. 因此,对于这些,不会调用setwd()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM