title: R sumif based on multiple conditions
body: <p>I'm trying to create summary tables based on the sum or average of other columns' values instead of by count.</p>
  <pre><code>Amount  Age ActualResult    Prediction
  100     20  Pass            Pass
  200     24  Pass            Pass
  300     30  Pass            Fail
  400     34  Pass            Fail
  500     40  Fail            Pass
  600     44  Fail            Pass
  700     50  Fail            Fail
  800     54  Fail            Fail
  </code></pre>
  <p>I can get a table by count using the following code:</p>
  <pre><code>table(data$ActualResult,data$Prediction)
  
  
              Predict Pass    Predict Fail
  Actual Pass 2               2
  Actual Fail 2               2
  </code></pre>
  <p>But I don't know how to get the table by sum of amount or average age:
  By Amount:</p>
  <pre><code>            Predict Pass    Predict Fail
  Actual Pass 300             700
  Actual Fail 1100            1500
  </code></pre>
  <p>By Avg Age:</p>
  <pre><code>            Predict Pass    Predict Fail
  Actual Pass 22              32
  Actual Fail 42              52
  </code></pre>
  <p>What code would I use to create the tables by amount and average age?</p>