Based on this solution, I have formulated the below code to perform chisq.test for 33 variables.
sapply(Indices,function(i){
chisq.test(data.cleaned[,i],data.cleaned$Out)$p.value })
This code produces 9 warnings, hopefully due to the violation of the assumptions made for chisq.test. I would like to identify for which instances of i the warnings are issued ?
I assume that there is no need of a reproducible example for this simple question from a beginner.
You could use
tryCatchand return warning messages from your anonymous function together with thechisq.testresult in alist.Example: