[R] how to extract specific subscript of a matrix

Jinsong Zhao j@zh@o @end|ng |rom ye@h@net
Thu Jun 11 02:29:10 CEST 2020


Hi there,

I have a matrix similar as:

M <- matrix(c(2,2,rep(1,12), 2), nrow = 5,byrow = FALSE)

I hope to get the border subscript of the block with value 1. In the 
above example, I hope to get:

(3,1), (5,1), (5,2), (4,2), (4,3), (1,3), (1,2), (3,2)

Is there any function can do that? or any implement idea? Thanks!

Best,
Jinsong



More information about the R-help mailing list