Matrices in R
Learning to work with data structures is critical for programming in R. Data structures are essential concepts in programming because efficient data storage and operartions rely on them.
In this second lesson of our interactive Data Structures in R course, you will continue adding to your R programming skills as you learn about matrices and how to create, modify, and work with them in R.
The good news is that to do this, you'll be reusing some skills from the vector mission as we dive deeper into creating, manipulating, and performing calculations with matrices.
A matrix is a two-dimensional data structure for storing values of same type. So like vectors, matrices can be of type logical, numeric (integer and double), and character. Matrices, being two-dimensional, introduce the notions of rows and columns, whereas a vector (of one-dimension) can be considered like a single column or a row.
Since most datasets come in row-and-column, spreadsheet-style format, being able to work with matrices is critical.
After you finish this lesson, you will be comfortable working with matrices, and you'll have a solid understanding of how they fit into the context of data analysis work with R.
- Creating a Matrix Restructuring a Vector
- Creating a Matrix Combining Vectors
- Naming Matrix Rows and Columns
- Indexing Matrices by Columns and Rows
- Indexing Matrices Using Vectors
- Modifying Elements in a Matrix
- Appending Elements to a Matrix
- Removing Elements from a Matrix
- Performing Operations with Matrices
- Scoring and Ranking Univerities
- Next Steps