# Creating Matrix Full of Zeros (i.e. 0) in R (Example Code)

This article illustrates how to create a zero-matrix in R programming.

## Example: Creating Matrix that Consists Only of Zeros Using matrix() Function

my_matrix <- matrix(0, # Create matrix full of zeros ncol = 6, nrow = 10) my_matrix # Display matrix in RStudio console # [,1] [,2] [,3] [,4] [,5] [,6] # [1,] 0 0 0 0 0 0 # [2,] 0 0 0 0 0 0 # [3,] 0 0 0 0 0 0 # [4,] 0 0 0 0 0 0 # [5,] 0 0 0 0 0 0 # [6,] 0 0 0 0 0 0 # [7,] 0 0 0 0 0 0 # [8,] 0 0 0 0 0 0 # [9,] 0 0 0 0 0 0 # [10,] 0 0 0 0 0 0 |

my_matrix <- matrix(0, # Create matrix full of zeros ncol = 6, nrow = 10) my_matrix # Display matrix in RStudio console # [,1] [,2] [,3] [,4] [,5] [,6] # [1,] 0 0 0 0 0 0 # [2,] 0 0 0 0 0 0 # [3,] 0 0 0 0 0 0 # [4,] 0 0 0 0 0 0 # [5,] 0 0 0 0 0 0 # [6,] 0 0 0 0 0 0 # [7,] 0 0 0 0 0 0 # [8,] 0 0 0 0 0 0 # [9,] 0 0 0 0 0 0 # [10,] 0 0 0 0 0 0

## Related Articles

In the following, you may find some additional resources that are related to the content of this page: