R Data StructuresLesson 20Free preview
R Matrices
This lesson is part of R · All levels
Summary
This study reviews the data structure of the Matrix in R which is a collection of two-dimensional elements lined and columned with homogeneous data types. Matrix is created using the matrix() function by specifying the parameters of the row (nrow) and column (ncol). Developers will learn how to access elements, combine matrices with cbind() or rbind(), as well as operations of linear algebra.
Key points
- Matrix is a two-dimensional data where all the elements must have the same type
- Created with the function 'matrix(data, nrow, ncol, byrow = FALSE)'
- By default, the data filing of the matrix is done per column (column-wise)
- Access the element using the notation square brackets: 'matrix[line, column]'
- The 'rbind()' and 'cbind()' functions combine new rows or columns into a matrix
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.