Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
471 views
in Technique[技术] by (71.8m points)

Try/try catch function in R

How can i use the try/try catch function in R to proceed to next loop and do sys.sleep for 60 seconds if the trycatch/try function returns an error. ANy help would be appreciated, thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

try this :

for (x in list(1,2,"a",4,5)){
  print(x)
  y <- try( x+1) # maybe you want try(x+1,silent=TRUE)
  if(inherits(y, "try-error")) Sys.sleep(5) 
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...