title: Is there an R function to get a table of expected counts?
body: <p>I have the following table of heartburn symptoms and response to two different medications:</p>
  
  <pre><code>           Medication
  Symptoms    Drug A Drug B Totals
    Heartburn     64     92    156
    Normal       114     98    212
    Totals       178    190    368
  </code></pre>
  
  <p>I'm looking for an <strong>R</strong> function that goes through the following operations to get the <em>expected</em> counts:</p>
  
  <pre><code>                    Medication
  Symptoms       Drug A                   Drug B               
  Heartburn     156 * 178 / 368 = 75      156 * 190 / 368 = 81 
  Normal        212 * 178 / 368 = 103     212 * 190 / 368 = 109
  </code></pre>
  
  <p>Ideally the display would even be optionally as follows:</p>
  
  <pre><code>           Medication
  Symptoms       Drug A   Drug B    Totals
    Heartburn     64(75)   92(81)    156
    Normal       114(103)  98(109)   212
    Totals       178      190        368
  </code></pre>
  
  <p>It's not too much to ask, is it?</p>