r - Identify every submatrix satisfying condition -
in following matrix i'm trying identify every largest rectangles formed 1's shown in picture. rectangles can have 1 row if have more 3 columns. rectangles can have 1 column if have more 3 rows. rectangles should have less maxcol columns , maxrow rows , more mincol , minrow. in picture mincol=minrow=2. maxrow=maxcolumn=6
tried use subset function provides 1's submatrixs not every superimposed rectangles.
mdat <- matrix(c(0,1,1,1,0,0,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,1,0), nrow = 4, ncol = 6, byrow = true) dimnames(mdat) <- list( c("row1", "row2", "row3","row4"), c("col1", "col2", "col3", "col4","col5","col6"))
Comments
Post a Comment