Chapter 17 Modifying iterations: break, next and while

In R, a standard looping sequence may be modified with the break, next and while statements.

17.2 break

The break statement is used inside a loop to terminate and exit the iteration when a certain condition is met.

for (val in x) {
    if (condition) {
        break
    }
    statement
}