March 2019
Beginner to intermediate
250 pages
6h 6m
English
You can access the elements in a matrix in a similar way to how you accessed elements of a vector using indexing. However, the elements here would be the index number of rows and columns.
Here a some examples of accessing elements:
m<-array(c(1,2,3,4,5,6), dim=c(2,3))m## [,1] [,2] [,3]## [1,] 1 3 5## [2,] 2 4 6m[1,2]## [1] 3
m[2,2]## [1] 4
m[2,]## [1] 2 4 6
m[,1]## [1] 1 2
Read now
Unlock full access