R Programming: Create a blank matrix
R Programming: Matrix Exercise-1 with Solution
Write a R program to create a blank matrix.
Sample Solution:
R Programming Code:
m = matrix(, nrow = 10, ncol = 5)
print("Empty matrix of 10 rows and 5 columns:")
print(m)
Sample Output:
[1] "Empty matrix of 10 rows and 5 columns:" [,1] [,2] [,3] [,4] [,5] [1,] NA NA NA NA NA [2,] NA NA NA NA NA [3,] NA NA NA NA NA [4,] NA NA NA NA NA [5,] NA NA NA NA NA [6,] NA NA NA NA NA [7,] NA NA NA NA NA [8,] NA NA NA NA NA [9,] NA NA NA NA NA [10,] NA NA NA NA NA
R Programming Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: R programming Matrix Exercises Home.
Next: Write a R program to create a matrix taking a given vector of numbers as input. Display the matrix.
Test your Programming skills with w3resource's quiz.
What is the difficulty level of this exercise?
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics