title: If observe warning, skip iteration in for loop [R]
body: <p>I have some loop that computes a value. Sometimes that computation triggers a warning. How do I check if the warning is triggered, then skip that iteration? I am using R.</p>
  <p>With help from the comments, I found tryCatch() and was able to amend my for loop as the following and work:</p>
  <pre><code>for (i in seq(1,100,1)){
      x&lt;-sample(1:length(df$values), 1)
      input&lt;-copy_df[x:x+5,]
      val&lt;-tryCatch(myfunc(input$colA), warning=function(w) w)
      if (is(val,warning){ 
          next
      }
      print(paste0(i))
  }
  </code></pre>
  <p>The output of val should be a column of length 5.</p>