I'd like to know if there is a way to combine two matrices with different dimensions into an array. I know there is the function abind(), but that function does not allow for different dimensions of the matrices. I need this because I use JAGS (with either R2jags or rjags) and these packages do not allow the data to be in list form. It does however work when I enter an array.
When I have the following two matrices:
a <- matrix(0, 3, 2)
b <- matrix(0, 4, 6)
a
[,1] [,2]
[1,] 0 0
[2,] 0 0
[3,] 0 0
b
[,1] [,2] [,3]
[1,] 0 0 0
[2,] 0 0 0
[3,] 0 0 0
[4,] 0 0 0
I would ideally have it like this:
abind(a,b, along = 3)
, , 1
[,1] [,2]
[1,] 0 0
[2,] 0 0
[3,] 0 0
, , 2
[,1] [,2] [,3]
[1,] 0 0 0
[2,] 0 0 0
[3,] 0 0 0
[4,] 0 0 0