[R] handling breaks in a for loop

akshay kulkarni
2022-02-06T18:55:43Z

dear members,
                         I have a very large for loop (basically a web scraping
loop) with 500 iterations(over different stocks). I am concerned about the loop
breaking midway.

My question is: is there any method to store the succesful iterations and
continue with the iteration (ofcourse, after fixing the bug) where the exception
occured? I can insert a save () function in the body of the loop and save the
succesful iterations but this would slow down the execution speed. Any other
method? I want to avoid trycatch as much as possible because an NA in the place
of a succesful iteration would cost me much.

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI

	[[alternative HTML version deleted]]