What are the loop types of R language?
This article mainly introduces the relevant knowledge of the loop type of R language, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this article on the loop type of R language. let's take a look.
What is a cycle?
Loop, which is used to do the same thing (that is, iteration) for multiple inputs of the same kind, such as doing the same operation for different columns and different data sets. Circular statements allow us to execute a statement or group of statements multiple times.
The loop types provided by the R language are:
Repeat cycle
While cycle
For cycle
The loop control statements provided by R language are:
Break statement
Next statement
Loop control statements change the order in which your code is executed, through which you can jump the code.
Loop type repeat
The repeat loop executes the code until the conditional statement is false, using the break statement to exit the loop. The syntax format is as follows:
Repeat {/ / related code if (condition) {break}}
The following example exits the loop when the variable cnt is 5, and cnt is the counting variable:
Instance repeat {v