title: R - How to get matrix from multidimensional array
body: <p>Suppose I've got 5D array <code>arr</code>.
  To get 2d matrix with fixed 3rd, 4th and 5th indices I do something like: <code>matr = arr[,,3,2,3]</code>. Suppose I've got list of indices <code>idx = c(3,2,3)</code>. Is there any way to get same result using <code>idx</code>? Something like <code>matr = arr[,,idx]</code>? I've tried to do it like </p>
  
  <pre><code>idx = c(,, 3, 2, 3);
  matr = arr[idx];
  </code></pre>
  
  <p>But it is obviously wrong.</p>
  
  <p><strong>UPD</strong> in a common case array may be more than 5 dimensional. So  I need to do this for idx of any size.</p>