R for loop skip to next iteration ifelse

前端 未结 1 1793
北海茫月
北海茫月 2020-12-04 17:15

Suppose you have a for loop like so

for(n in 1:5) {
  #if(n=3) # skip 3rd iteration and go to next iteration
  cat(n)
}

How would one skip

相关标签:
1条回答
  • 2020-12-04 17:44
    for(n in 1:5) {
      if(n==3) next # skip 3rd iteration and go to next iteration
      cat(n)
    }
    
    0 讨论(0)
提交回复
热议问题