# Lesson: 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 lesson 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.

#### Objectives

• Learn about matries and why they're useful.
• Create, modify, and perform operations with matrices.
• Try scoring and ranking universities using matrices in R.

#### Lesson Outline

1. Creating a Matrix Restructuring a Vector
2. Creating a Matrix Combining Vectors
3. Naming Matrix Rows and Columns
4. Indexing Matrices by Columns and Rows
5. Indexing Matrices Using Vectors
6. Modifying Elements in a Matrix
7. Appending Elements to a Matrix
8. Removing Elements from a Matrix
9. Performing Operations with Matrices
10. Scoring and Ranking Univerities
11. Next Steps