title: Combining matrices with different dimensions in an array in R
body: <p>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.</p>
  
  <p>When I have the following two matrices:</p>
  
  <pre><code>a &lt;- matrix(0, 3, 2)
  b &lt;- 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
  </code></pre>
  
  <p>I would ideally have it like this:</p>
  
  <pre><code>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
  </code></pre>