r - How to pause R script when error
问题描述
I would like to use sys.sleep function when the request of an API I am using gives me an error back. Like this one:
Error in open.connection(con, "rb") : HTTP error 429.
Should I use trycatch?
data<- fromJSON("https://api.com")
Thanks !
解决方案
您可以使用尝试捕获
tryCatch(myfunc(), error=function(e) Sys.sleep(1))
推荐阅读
- sql - 临时更改 SQL 查询输出中日期列的格式 MM/YY -> MM/DD/YYYY
- swift - GameplayKit 最长路径
- python - 从多维背包算法中获取最优解的信息
- visual-studio-code - 如何使用多个 extensionDevelopmentPath 源启动 VSCode?
- ubuntu - VirtualBox:Ubuntu:Maven org.apache.maven.plugins:maven-install-plugin:2.4 或其依赖项之一无法解析
- php - PHP - 获取多维数组范围之间的数组元素
- jmeter - 在 jmeter 中使用 XPATH - 基于父级
- amazon-web-services - 按月显示所有正在运行的实例
- angularjs - 如何使用回调重构链接的 $http 调用和库调用
- scala - 为什么我不能在我的程序中使用 UpdateStateByKey?