tony8310的个人博客分享 http://blog.sciencenet.cn/u/tony8310

博文

R 无视错误继续执行代码 option(error=...)

已有 962 次阅读 2023-4-10 13:17 |系统分类:科研笔记

http://web.mit.edu/r/current/lib/R/library/base/html/options.html

  • error:

  • either a function or an expression governing the handling of non-catastrophic errors such as those generated bystop as well as by signals and internally detected errors.  If the option is a function, a call to that function, with no arguments, is generated as the expression.  The default value is NULL: see stop for the behaviour in that case.  The functions dump.frames andrecover provide alternatives that allow post-mortem debugging.  Note that these need to specified as e.g. options(error = utils::recover) in startup files such as ‘.Rprofile’.

# 在访问某些网站时,可能超时,出现错误。这时R无法继续执行下面的代码。

# 需要跳过错误,继续运行下面的代码。可以设置option(error=...)
# Will continue to execute script even after error, when options()$error is not NULL
options(error = function(){cat('continue to execute script even after error.\n')})



https://wap.sciencenet.cn/blog-331295-1383646.html

上一篇:Windows 11 安装AutoCAD 出错,无法安装 netfx3 的解决方法
下一篇:录屏+摄像头
收藏 IP: 202.113.99.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-28 13:25

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部