title: How to sum a substring reference
body: <p>I'm attempting to select the correct column to sum the total of a from within a data frame column using ddply:</p>
  
  <pre><code>df2 &lt;- ddply(df1,'col1', summarise, total = sum(substr(variable,1,3)))
  </code></pre>
  
  <p>It appears not to be working because you can't sum a character, but I am trying to pass the reference to the column, not sum the literal result of the substring. Is there a way to get around this?</p>
  
  <p>Example Data &amp; Desired output:</p>
  
  <p>variable = "Aug 2017"</p>
  
  <p><code>
      col1 Jun Jul Aug
  1     A   1   2   3
  2     A   1   2   3
  3     A   1   2   3
  4     A   1   2   3
  5     A   1   2   3
  6     B   2   3   4
  7     B   2   3   4
  8     B   2   3   4
  9     C   3   4   5
  10    C   3   4   5
  </code>
  <code>
  Desired Output:
  1     A   15<br>
  2     B   12
  3     C   10
  </code></p>