On Tue, Jun 12, 2012 at 11:44:51AM -0500, Michael wrote: > Hi all, > > Lets say I have a matrix A which is m x n. > > I also have a mask matrix MASK which is m x n with values in T/F, where T > values make a sub-matrix in regutangular shape... > > I applied B=A[MASK] and it didn't work as expected...
Hi. Try the following. A <- matrix(1:16, nrow=4, ncol=4) B <- matrix(FALSE, nrow=4, ncol=4) B[2:3, 2:3] <- TRUE A[rowSums(B) != 0, colSums(B) != 0] [,1] [,2] [1,] 6 10 [2,] 7 11 Hope this helps. Petr Savicky. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.