While and Repeat Loop in R Programming

Premium

The general format of the while statement is:

1while (condition) {
2  statement
3}
4

Note that a while loop may never execute the statement. The statement is executed repeatedly until condition becomes false.

In contrast, a repeat loop has the general format as below:

1repeat {
2  print('test')
3}
4

Unlock Premium Content

Upgrade your account to access the full article, downloads, and exercises.

You'll get access to:

  • Access complete tutorials and examples
  • Download source code and resources
  • Follow along with practical exercises
  • Get in-depth explanations