用sweave显示错误 [英] Displaying errors with sweave

查看:72
本文介绍了用sweave显示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Sweave编写一些R笔记,并希望显示常见的错误.例如

I'm writing some R notes with Sweave and would like to show common errors. For example,

<<echo=TRUE, eval=TRUE>>=
x = 5
#Case matters!
x*X
@

但是,在编织时,由于R错误而无法编译文档.有什么方法可以使sweave编译并显示(格式正确的)错误?

However when sweaving, the document won't compile due to the R error. Is there any way to make sweave compile and show the (nicely formated) error?

推荐答案

如Shane建议的那样,使用

As Shane suggests, use

<<echo=TRUE,eval=FALSE>> 

对于将出错但您要显示的代码,然后再次使用

for the code that will error, but you want to display, and then again with

<<echo=FALSE,eval=TRUE,results=verbatim>> 

,但尝试时使用相同的代码.

but with the same code wrapped in a try.

这里有一个例子: http://tolstoy.newcastle.edu.au/R/help /05/09/11690.html

这篇关于用sweave显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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