title: Rendering multidimension contingency table
body: <p>I am looking at advice and suggestion on how I can get to render multi dimension contingency table using Shiny in R.</p>
  
  <p>I have tried using tableoutput and rendertable to render flat contingency tables generated using ftable. However I was able to get it to render it properly only when I had single dimension on each axis (x and y). As soon as the number of dimensions on either axis increased, the rendering fell off. (for below example the labels started appearing as 0_3, 0_4, etc..  on y axis and four_0, four_1, etc.. on x-axis which did not look good)
  I am looking for rendering something like below UI.</p>
  
  <p>Here is what I have done so far:</p>
  
  <p><strong><em>UI</em></strong>:</p>
  
  <pre><code>mainPanel(
      tableOutput("tableDF")
  )
  </code></pre>
  
  <p><strong><em>Server</em></strong>:</p>
  
  <pre><code>observeEvent(input$inShow, {
      grp_cols &lt;- input$inDimensions
      obs &lt;- main_table$data
      dots &lt;- lapply(grp_cols, as.symbol)
      tableop &lt;- ftable(obs[grp_cols])
      output$tableDF &lt;- renderTable(as.matrix(tableop),rownames = T)
  })
  </code></pre>
  
  <p>However if more than 2 dimensions are selected then here is how it looks currently (2 dimensions on Y - axis and 1 on Y-axis). ( Has F_, M_ values on Y-axis for combining the two dimensions Gender and other attribute on which ftable is applied)</p>
  
  <p><a href="https://i.stack.imgur.com/wvZg9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wvZg9.png" alt="With 2 dimensions on y-axis and 1 on x-axis"></a></p>
  
  <p>I am looking for a better formatted output like shown below when there are more than 2 dimensions.</p>
  
  <p><a href="https://i.stack.imgur.com/fSTId.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fSTId.png" alt="Multidimensional contingency table"></a></p>