Erich STRIESSNIG wrote: > Hi all, > > Can anybody tell me what to do in case an error occurs inside a > for-loop and I don't want the program to exit the loop? Rather instead > I would like it to just go to the next number in the loop and try > again with the new number. Is there any function like "on error go > back to" or "skip error" ... ?
there's the keyword 'next' in r which you could use to proceed to the next value in a for loop. you can also use try({...}) within the loop, e.g.: for (i in 0:3) try({if (i==2) stop(i); print(i)}, silent=TRUE) [1] 0 [1] 1 [1] 3 vQ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.