matrices and scripts
A matrix is another kind of R-Object. Matrices are used for math operations, such as linear algebra and solving systems of equations. We wonโt work with them that much in this course, but it is important to know how to use them as they can be used in more complex statistical analysis done in R.
MyMatrix = matrix(c(3:20), nrow = 3, ncol = 6, byrow = FALSE)
MyMatrix
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 3 6 9 12 15 18
## [2,] 4 7 10 13 16 19
## [3,] 5 8 11 14 17 20Notes
R places indicators in square brackets [] to help navigate the matrix.
The colon : is a little cheat for making a vector that increases in increments of 1 between the numbers.
vec = c(4:15)
vec
## [1] 4 5 6 7 8 9 10 11 12 13 14 15