I create a matrix in R with 10x10 (10 rows and 10 columns):
matriz <- matrix(1:100, nrow = 10, ncol = 10, byrow=T)
I want to extract square submatrices (3x3) from matrix (matriz), randomly and without overlap.
I see a package in R named "subset.matrix", but I couldn't in randomly matrix.
Any suggestion?
I agree with the comment from user2974951 regarding randomness. However, this code block will do what you asked.
Instead of a set number of attempts for the loop, you could use a counter. With 50 attempts, I get 4-6 sub-matrices. 1000 gives 6-8.