how to see if any element of a list contains only a certain value in R

I have a list of many matrices, let say my_list. I want to check if any of those matrices has only zero s as its element and if so which matrix in that list has such situation.

library(R.utils)
output_vec <- vector()
for(i in 1:length(my_list)){
   asZero(as.vector(my_list[[i]]))}

this gives me true falses but, I am not able to return the index of matrices with all zero elements. I appreciate any help with this.



Read more here: https://stackoverflow.com/questions/68462148/how-to-see-if-any-element-of-a-list-contains-only-a-certain-value-in-r

Content Attribution

This content was originally published by Mathica at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: