Breaking out of nested loops in R
问题 Very simple example code (only for demonstration, no use at all): repeat { while (1 > 0) { for (i in seq(1, 100)) { break # usually tied to a condition } break } break } print("finished") I want to break out from multiple loops without using break in each loop separately. According to a similar question regarding python, wrapping my loops into a function seems to be a possible solution, i.e. using return() to break out of every loop in the function: nestedLoop <- function() { repeat { while