Skip to content
Prev 200643 / 398503 Next

reduce matrix

one way is the following:

A <- rbind(c(1,0,0,3), c(0,1,2,0), c(0,0,3,5))
t(apply(A, 1, function (x) x[x != 0]))


I hope it helps.

Best,
Dimitris
lloyd barcza wrote: