简体   繁体   English

eval = FALSE的块仍在R Sweave上求值

[英]Chunk with eval=FALSE still evaluates on R Sweave

I'm working on some education manuals in spanish for a course, so I'm making a Sweave document with some chunks and I'm trying to make an example of an error message. 我正在用西班牙语编写一些教育手册,因此我正在制作带有一些块的Sweave文档,并尝试举一个错误消息的例子。 But first I need to show the souce of that error, so I'm using this code, since I don't want the code evaluating I'm using eval=FALSE: 但是首先我需要显示该错误的根源,所以我正在使用此代码,因为我不希望代码评估使用eval = FALSE:

<<eval=FALSE, error=TRUE,tidy=FALSE>>=
c(1,2 3)
#falta una coma
@

But the code is still evaluating and it's not letting me print the document, giving me this error message 但是代码仍在评估中,并且不允许我打印文档,从而给我此错误消息

(chunk 306) 5305:7: unexpected numeric constant (块306)5305:7:意外的数字常量

Your code is being parsed, not evaluated. 您的代码正在解析,而不是评估。 If you have current versions of the knitr and evaluate , this should result in a warning in the knitr log, it won't stop the run. 如果您具有最新版本的knitrevaluate ,这会在knitr日志中导致警告,它不会停止运行。 I'm using knitr 1.16 and evaluate 0.10.1 and things are fine. 我正在使用knitr 1.16并evaluate 0.10.1,一切正常。 See knitr: knitting chunks with parsing errors for a bit more on this. 有关更多信息,请参见knitr:编织带有解析错误的块

(BTW, I think you're using knitr , not Sweave . They're different. Sweave can't handle this. If you really are using Sweave , switch to knitr . The switch is not hard, and brings a lot of benefits.) (顺便说一句,我认为您使用的是knitr而不是Sweave 。它们是不同的Sweave无法处理此问题。如果您确实使用Sweave ,请切换到knitr 。切换并不困难,并且带来了很多好处。 )

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

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