R Script - How to Continue Code Execution on Error

后端 未结 3 1978
挽巷
挽巷 2020-11-30 08:37

I have written an R script which includes a loop that retrieves external (web) data. The format of the data are most of the time the same, however sometimes the format chang

3条回答
  •  执笔经年
    2020-11-30 09:10

    You can use try:

    # a has not been defined
    for(i in 1:3)
    {
      if(i==2) try(print(a),silent=TRUE)
      else print(i)
    }
    

提交回复
热议问题