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 (1 > 0) {
      for (i in seq(1, 100)) {
        return()
      }
    }
  }
}
nestedLoop()
print("finished")
Are there other methods available in R? Maybe something like labeling loops and then specifying which loop to break (like in Java) ?
 
     
     
    