I have a matrix, I want to only keep those rows in which at least one member is more than 5. I mean those rows whose members all are less than 5 should be filtered out.
for example:
2 4 6 2 1
1 2 3 1 2
5 4 7 2 1
in this matrix, the second row should be filtered out because all of its members are less than 5.
here is what I write:
for(i in 1:length(matrix[,1]){
for(j in 2:17){
if(any(matrix[i,j]>=5)){matrix=matrix} else {matrix=matrix[-i,]}
}}
But it doesn't work.
what do you think I can do?