Create a 5 by 5 matrix consisting of the numbers 1-25 and assign it to the variable mat2. The top row should be the numbers 1-5.Using indexing notation, grab a subsection of mat2 that looks like this:
[ 7, 8]
[12,13]
Let us create a matrix of 5 by 5 consisting of numbers 1-25.
mat2 <- matrix(1:25,byrow = TRUE,nrow = 5)
mat2
Now to grab a subset of mat2, we can do the following.
mat2[2:3,2:3]
Output:
7 8
12 13