Displaying errors with sweave

前端 未结 3 1037
误落风尘
误落风尘 2021-01-05 00:19

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

<>=
x = 5
#Case matters!
x*X
@
         


        
3条回答
  •  执笔经年
    2021-01-05 01:06

    Wrap your error in a try() command. Then it will keep running:

    > {print(1); try(x*X); print(2)}
    [1] 1
    Error in try(x * X) : object 'X' not found
    [1] 2
    

提交回复
热议问题