concept condition in category R

This is an excerpt from Manning's book Beyond Spreadsheets with R.
You can evaluate this with a “large” value (less than
10is the condition required to avoid the error; execution will stop if the condition is not true):
If the condition never evaluates to
TRUE, then the body is never executed:while (1 == 2) { print("this line will not be printed") }The condition in the
whilestatement needs to be valid, which means that any variables it depends on need to already exist. One way to deal with this is to be explicit about the first value by initializing it outside of thewhilestatement. Within the body of the loop, the variable(s) can (and should) be updated. Here’s a simplewhileloop that prints the current value ofion each iteration and then increases it by1until it is no longer less than3:i <- 0 #1 while (i < 3) { #2 print(i) #3 i <- i + 1 #4 } #> [1] 0 #> [1] 1 #> [1] 2 #1 Initializes i to 0 #2 The condition of the loop is that i is less than 3, which it is to begin with. #3 On each iteration, the value of i is printed. #4 At the end of each iteration, i is increased by 1.