For the next cycle - Receive error

I've tried the following simple one for the next loop in R programming:

for(i in 1:100)  { if(i <= 20)  {  next  } print(i) }

      

Below is the error message:

Error: unexpected symbol in "for(i in 1:100) { if(i <= 20) {next} print"

      

Please help me understand why I am getting the error.

+3


source to share


2 answers


Take a picture:

for (i in 1:100) { 
  if (i<=20) {
    next
  };
  print(i)
}

      



It looks like you missed your half of the colon. This is to mark the end of the instruction.

+1


source


you need to split the line (enter) after {next} and print (i)} on another line. :) Good luck



0


source







All Articles