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
tryCatch
and return warning messages from your anonymous function together with thechisq.test
result in alist
.Example: