title: R: combine two 2-dimensional crosstabs
body: <pre><code>&gt; t &lt;- read.csv("data.csv", sep=';')
  &gt; t
       sex pacemaker  smoker
  1 female        no   never
  2 female        no   never
  3   male        no   never
  4   male        no  former
  5   male       yes  former
  6   male       yes  former
  7 female       yes current
  8 female       yes  former
  9 female        no current
  &gt; xtabs(~smoker+sex, data=t)
                sex
  smoker    female male
    current      2    0
    former       1    3
    never        2    1
  &gt; xtabs(~smoker+pacemaker, data=t)
           pacemaker
  smoker    no yes
    current  1   1
    former   1   3
    never    3   0
  </code></pre>
  
  <p>How can I combine two 2-dimensional crosstabs in R ?</p>
  
  <p>Desired output:</p>
  
  <pre><code>          |     sex      |  pacemaker
    smoker  | female male  |   no  yes
    current |    2    0    |    1   1
    former  |    1    3    |    1   3
    never   |    2    1    |    3   0
  </code></pre>