Skip to contents

Returns a matrix filled with zeros, with dimensions specified by the user. If dimensions are not provided, a 1 x 1 zero matrix will be returned.

Usage

stm_zeros(nrows, ncols = nrows)

Arguments

nrows

Optional. The number of rows in the matrix. Defaults to 1 if not specified. Must be a positive integer.

ncols

Optional. The number of columns in the matrix. If NULL, it defaults to the same value as nrows. Must also be a positive integer.

Value

A matrix filled with zeros, with dimensions defined by nrows and ncols. Returns an empty matrix with dimensions (0, 0) if either dimension is zero.

Examples

stm_zeros(nrows = 4)
#>      [,1] [,2] [,3] [,4]
#> [1,]    0    0    0    0
#> [2,]    0    0    0    0
#> [3,]    0    0    0    0
#> [4,]    0    0    0    0
stm_zeros(nrows = 3, ncols = 3)
#>      [,1] [,2] [,3]
#> [1,]    0    0    0
#> [2,]    0    0    0
#> [3,]    0    0    0
stm_zeros(nrows = 2, ncols = 4)
#>      [,1] [,2] [,3] [,4]
#> [1,]    0    0    0    0
#> [2,]    0    0    0    0