title: Using results of a match to create a win/loss record
body: <p>If I have data.frame comprising of a date and a result (W or L), how can I use the result to create a record of results? For example, if I have:</p>
  
  <pre><code>df
          date     Result
  # 1  2015-04-12    W
  # 2  2015-04-10    W
  # 3  2015-04-09    W
  # 4  2015-04-08    W
  # 5  2015-04-08    L
  # 6  2015-04-07    W
  # 7  2015-04-06    L
  </code></pre>
  
  <p>How can I get something like:</p>
  
  <pre><code>df
          date     Result   Wins   Losses
  # 1  2015-04-12    W       5        2
  # 2  2015-04-10    W       4        2
  # 3  2015-04-09    W       3        2
  # 4  2015-04-08    W       2        2
  # 5  2015-04-08    L       1        2
  # 6  2015-04-07    W       1        1
  # 7  2015-04-06    L       0        1
  </code></pre>
  
  <p>All of the "solutions" I have come up with just add a 1 to each column depending on win or loss. For example:</p>
  
  <pre><code>for(i in 1:dim(df)[1]) {
    if(df$Result[i] == "W") {
      df$Wins[i] &lt;- + 1
    }
    if(df$Result[i] == "L") {
       df$Losses[i] &lt;- + 1
    }
  }
  </code></pre>
  
  <p>Thank you. Any and all help is appreciated.</p>