w3resource

R Programming Matrix: Exercises, Practice, Solution

[An editor is available at the bottom of the page to write and execute the scripts.]

R Programming Matrix [13 exercises with solution]

1. Write a R program to create a blank matrix. Go to the editor
Click me to see the sample solution

2. Write a R program to create a matrix taking a given vector of numbers as input. Display the matrix. Go to the editor
Click me to see the sample solution

3. Write a R program to create a matrix taking a given vector of numbers as input and define the column and row names. Display the matrix. Go to the editor
Click me to see the sample solution

4. Write a R program to access the element at 3rd column and 2nd row, only the 3rd row and only the 4th column of a given matrix. Go to the editor
Click me to see the sample solution

5. Write a R program to create two 2x3 matrix and add, subtract, multiply and divide the matrixes. Go to the editor
Click me to see the sample solution

6. Write a R program to create a matrix from a list of given vectors. Go to the editor
Click me to see the sample solution

7. Write a R program to extract the submatrix whose rows have column value > 7 from a given matrix. Go to the editor
Click me to see the sample solution

8. Write a R program to convert a matrix to a 1 dimensional array. Go to the editor
Click me to see the sample solution

9. Write a R program to create a correlation matrix from a dataframe of same data type. Go to the editor
Click me to see the sample solution

10. Write a R program to convert a given matrix to a list of column-vectors. Go to the editor
Click me to see the sample solution

11. Write a R program to find row and column index of maximum and minimum value in a given matrix. Go to the editor
Click me to see the sample solution

12. Write a R program to rotate a given matrix 90 degree clockwise rotation. Go to the editor
Click me to see the sample solution

13. Write a R program to concatenate two given matrices of same column but different rows. Go to the editor
Click me to see the sample solution

R Programming Code Editor:


More to Come !

Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.