I have a 200x200 matrix containing count information. I would like to randomly sample a 5 row x 5 column subset within my matrix and take the average of the counts within this subset. I want to do this 8 times randomly throughout my matrix (so maybe use a for-loop?) and then take the averages of these 8. I also need to use restrictions so that the random number generator doesn't sample at the very edge of my matrix.
I am new to R and programming in general, so a push in the right direction would be very helpful.