Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the loop types of R language?

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report