Expand an array to a given dimension by repeating its entries in the directions where the array has dimension one.
expandArray(x, dy)
An object that is coerced to array.
The dimensions it is to be expanded to.
An array that consists of the entries in x
, with dimension dy
.
Throws an error if the array and dimensions are not compatible.
x <- 1:3
expandArray(x, c(3,4))
#> [,1] [,2] [,3] [,4]
#> [1,] 1 1 1 1
#> [2,] 2 2 2 2
#> [3,] 3 3 3 3