Skip to content
Prev 374730 / 398513 Next

Using tryCatch in a for loop

After Dan's suggestions I went back to testing the code outside the for loop again and realized I haven't included a lake that WILL have a breakpoint in my "test" dataset. Below I provide data where some of the lakes produce warnings and others produce results. The output is the matrix I want (as I described previously) but the "warning" is printed outside the final matrix. So I get results for lakes 2 and 4 but there isn't a warning written for Lake 1 and 3 in the final matrix. This is much closer so thank you Dan! Is there any way to get the final result with "warning" written in for lakes without breakpoints so that I can write it into a .csv?


Bailey