We reproduce a memory representation of the matrix in R with the matrix function. The data elements must be of the same basic type.
+ c(2, 4, 3, 1, 5, 7), # the data elements
+ nrow=2, # number of rows
+ ncol=3, # number of columns
+ byrow = TRUE) # fill matrix by rows
> A # print the matrix
[,1] [,2] [,3]
[1,] 2 4 3
[2,] 1 5 7
An element at the mth row, nth column of A can be accessed by the expression A[m, n].
The entire mth row A can be extracted as A[m, ].
Similarly, the entire nth column A can be extracted as A[ ,n].
We can also extract more than one rows or columns at a time.
If we assign names to the rows and columns of the matrix, than we can access the elements by names.