title: Create new R dataframe column based on conditions in other columns
body: <p>I have a dataframe which has a date column, a column of ints (labelled <code>value</code> in the example below), and 12 other numeric columns, each corresponding to a month and labelled <code>X1</code> (jan) through <code>X12</code> (dec).</p>
  
  <p>It looks something like:</p>
  
  <pre><code>date_var    value    X1       X2      X3     ...   X12
  2016-01-01   100    1212     4161    9080    ...   383
  2016-02-01   150    1212     4161    9080    ...   383
  2016-03-01   150    1212     4161    9080    ...   383
  </code></pre>
  
  <p>What I'd like to do is create a new column, lets call it Z, which corresponds to the number in the <code>value</code> column, divided by the appropriate monthly value.</p>
  
  <p>For example, in the table above Z for the <code>2016-01-01</code> entry would equal 100/1212, whereas the <code>2016-02-01</code> entry would instead divide by X2 for Feb and <code>2016-03-01</code> would have <code>value</code> divided by X3:</p>
  
  <pre><code>date_var    value    X1       X2      X3     ...   X12    Z
  2016-01-01   100    1212     4161    9080    ...   383    0.0825
  2016-02-01   150    1212     4161    9080    ...   383    0.0360
  2016-03-01   150    1212     4161    9080    ...   383    0.0165
  </code></pre>
  
  <p>I've tried various approaches along the lines of attempting to divide <code>value</code> by <code>df[paste("X", month(df$date_var), sep = '')]</code>, although this returned list a rather than working element-wise so obviously isn't the correct approach.</p>