Assignment on Matrix in R

Let’s use an example of dinner plans for this assignment. We have done this with Vectors. But this time, we will use Matrix.
Problem:
Let’s plan what to cook for dinner this week (Monday- Friday). 
Solution:

Let’s use the features we learned already.

1. Create 2 Vectors. One for the Entree and then another one for the sides. How to create a Vector is posted here.
2. Next, Let’s create a Matrix using the above 2 vectors. How to create a Matrix is posted here.

3. Now, let’s name the rows and columns for the Matrix. It will help to display what to eat on what day. If required, the ways to name the rows and columns of a Matrix is available here.

4. Finally, accessing the elements of the Matrix. If we want to display what to eat on each day of the week, the process is posted here.

And, that’s all, We are done!
0

Leave a Reply

Your email address will not be published. Required fields are marked *