title: How to get column index matrix of an array in R?
body: <p>Imagine I have a simple 4x3x2 array in R.</p>
  
  <pre><code>&gt; x &lt;- array(1:24,c(4,3,2), dimnames=list(c('a','b','c','d'),c('x','y','z'),1:2))
  &gt;  x
  , , 1
  
    x y  z
  a 1 5  9
  b 2 6 10
  c 3 7 11
  d 4 8 12
  
  , , 2
  
     x  y  z
  a 13 17 21
  b 14 18 22
  c 15 19 23
  d 16 20 24
  </code></pre>
  
  <p>What I'd like, is a simple function on the array that gives me back the name of the index of each element for an arbitrary dimension. In this case, dimension 2.</p>
  
  <p>The function would behave like this:</p>
  
  <pre><code>&gt; arraydims(x,2)  #Where 2 is dimension I want names for.
  
  , , 1
  
       [,1] [,2] [,3]
  [1,] "x"  "y"  "z" 
  [2,] "x"  "y"  "z" 
  [3,] "x"  "y"  "z" 
  [4,] "x"  "y"  "z" 
  
  , , 2
  
       [,1] [,2] [,3]
  [1,] "x"  "y"  "z" 
  [2,] "x"  "y"  "z" 
  [3,] "x"  "y"  "z" 
  [4,] "x"  "y"  "z" 
  </code></pre>