MathsGee Answers is Zero-Rated (You do not need data to access) on: Telkom |Dimension Data | Rain | MWEB
First time here? Checkout the FAQs!
Institutions: Global |ALU | Ekurhuleni Libraries | Joburg Libraries | Tshwane Libraries | TUT | UCT | UJ | UNISA | UP | UZ | Wits | Invest in Zim

MathsGee is Zero-Rated (You do not need data to access) on: Telkom |Dimension Data | Rain | MWEB

1 like 0 dislike
What is the purpose of using Next statement in R language?
in Causal Data Science by Diamond (60,788 points) | 104 views

1 Answer

0 like 0 dislike
Best answer

A next statement is useful when we want to skip the current iteration of a loop without terminating it. On encountering next, the R parser skips further evaluation and starts next iteration of the loop.

The syntax of next statement is:

if (test_condition) {

Note: the next statement can also be used inside the  else branch of if...else statement.

Next statement

x <- 1:5
for (val in x) {
if (val == 3){


[1] 1
[1] 2
[1] 4
[1] 5

In the above example, we use the next statement inside a condition to check if the value is equal to 3.

If the value is equal to 3, the current evaluation stops (value is not printed) but the loop continues with the next iteration.

The output reflects this situation.

by Diamond (60,788 points)

Related questions

0 like 0 dislike
0 answers
1 like 0 dislike
1 answer
0 like 0 dislike
0 answers
asked Mar 12, 2019 in Causal Data Science by MathsGee Diamond (60,788 points) | 30 views

Welcome to MathsGee Answer Hub, a free online study network where students can ask, answer, and explore 24/7 for improved outcomes.

MathsGee Supporting City of Joburg

Enter your email address:

MathsGee Tools

Math Worksheet Generator

Math Algebra Solver

Trigonometry Simulations

Vectors Simulations

Matrix Arithmetic Simulations

Matrix Transformations Simulations

Quadratic Equations Simulations

Probability & Statistics Simulations

PHET Simulations

Visual Statistics

Interactive Courseware

ZeroEd Search Engine

Article Rewriter Tool

Word Counter Tool

Other Tools

STEM Gender Equality | ZOOM | Slack | eBook

14,433 questions
10,906 answers
13,750 users