3
I have the following problem, I have a matrix and I want to go through it and get the first line that has all the elements other than zero. For example:
a = matrix(c(rep(0,4), 1:16), ncol = 4, byrow = T)
b = matrix(c(1:4, rep(0,4), 5:16), ncol = 4, byrow = T)
d = matrix(c(1:8,rep(0,4) , 9:16), ncol = 4, byrow = T)
The answer to "a" would be line 2, the answer to "b" would be line 1 and the answer to "d" would be line 1.
Thanks in advance.
Daniel, I expressed myself wrong, I want you to return the elements of the matrix, that is, all the elements of line 2, 1 and 1.
– Wagner Jorge
I’ll edit, but it’s just one more line!
– Daniel Falbel