title: How to identify the warning generated instances of an operation in a loop?
body: <p>Based on this <a href="https://stackoverflow.com/a/24359874/4836511">solution</a>, I have formulated the below code to perform <code>chisq.test</code> for 33 variables.</p>
  
  <pre><code>sapply(Indices,function(i){
    chisq.test(data.cleaned[,i],data.cleaned$Out)$p.value })
  </code></pre>
  
  <p>This code produces 9 warnings, hopefully due to the violation of the assumptions made for <code>chisq.test</code>. I would like to identify for which instances of <code>i</code> the warnings are issued ?</p>
  
  <p>I assume that there is no need of a reproducible example for this simple question from a beginner.</p>