Home » R Next Statement

R Next Statement

by Online Tutorials Library

R next Statement

The next statement is used to skip any remaining statements in the loop and continue executing. In simple words, a next statement is a statement which skips the current iteration of a loop without terminating it. When the next statement is encountered, the R parser skips further evaluation and starts the next iteration of the loop.

This statement is mostly used with for loop and while loop.

Note: In else branch of the if-else statement, the next statement can also be used.

Syntax

There is the following syntax for creating the next statement in R

Flowchart

R next statement

Example 1: next in repeat loop

Output:

R next statement

Example 2: next in while loop

Output:

R next statement

Example 3: next in for loop

Output:

R next statement

Example 4

Output:

R next statement

Example 5

Output:

R next statement


Next TopicR Break Statement

You may also like