Next Element In A Loop If Error In R

[Solved] Next Element In A Loop If Error In R | Perl - Code Explorer | yomemimo.com
Question : next element in a loop if error in r

Answered by : trustworthy-whale

# This solution still prints the error but doesn't stop the loop
for (i in 1:10) { tryCatch({ print(i) if (i==7) stop("Urgh, the iphone is in the blender !") }, error=function(e){cat("ERROR :",conditionMessage(e), "\n")})
}
[1] 1
[1] 2
[1] 3
[1] 4
[1] 5
[1] 6
[1] 7
ERROR : Urgh, the iphone is in the blender !
[1] 8
[1] 9
[1] 10

Source : https://stackoverflow.com/questions/14748557/skipping-error-in-for-loop | Last Update : Fri, 24 Sep 21

Answers related to next element in a loop if error in r

Code Explorer Popular Question For Perl