Create new matrix copying dimensions from the existing one
with_same_dims(mat, data)
mat | a matrix with desired dimensions |
---|---|
data | sigle numeric value or numeric vector |
a matrix
#> [,1] [,2] [,3] [,4] [,5] [,6] #> [1,] 7 7 7 7 7 7 #> [2,] 7 7 7 7 7 7 #> [3,] 7 7 7 7 7 7with_same_dims(x, 0)#> [,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#> [,1] [,2] [,3] [,4] [,5] [,6] #> [1,] 1 2 1 2 1 2 #> [2,] 2 1 2 1 2 1 #> [3,] 1 2 1 2 1 2