title: Adding a matrix to the first dimension of a 3D array
body: <p>I am sorry if the title is not very accurate, I did not find a simple way to put it. I am having trouble with a seemingly simple operation in R.</p>
  
  <p>Let's say I have a matrix A 2x2 (with elements Aij i=1,2 j=1,2), and I want to "transform" this matrix in a 3 dimensional array B 2x2x2 where: Bhij= Aij for h=1,2. 
  I have the following code:</p>
  
  <pre><code>A=cbind(c(1,2), c(3,4))
  B&lt;-array(NA, dim=c(2,2,2)
  for (h in 1:2){
     B[h,,]&lt;-A
  }
  </code></pre>
  
  <p>But I would want to do the same thing without using loop. Is there a way to do that? </p>
  
  <p>Thank you very much,</p>
  
  <p>Aurélien</p>