Skip to contents

stm_ones_like() generates a matrix or vector of ones that matches the dimensions of the provided input matrix or vector.

Usage

stm_ones_like(vmat)

Arguments

vmat

A matrix or vector whose dimensions will be used to generate the matrix or vector of ones.

Value

A matrix or vector of the same dimensions as vmat, filled with ones.

Details

The function checks the validity of the input vmat, converting it to a matrix if it is a vector. It then generates a matrix of ones of the same size as vmat.

See also

Examples

A <- matrix(1:12, nrow = 3, byrow = TRUE)
stm_ones_like(A)
#>      [,1] [,2] [,3] [,4]
#> [1,]    1    1    1    1
#> [2,]    1    1    1    1
#> [3,]    1    1    1    1
stm_ones_like(c(1, 2, 3))
#>      [,1]
#> [1,]    1
#> [2,]    1
#> [3,]    1