Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the loop types of R language?

Shulou Source: shulou.com Published: 2022-06-02 01:12:43 10月11日 Update

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

Tags: Loop statement language code instance type variable input letter format result grammar condition control output same content knowledge different vector Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info vpn Redmi OPPO Reno Shulou Information