title: Create new dataframe column using lapply that is sum of specific columns
body: <p>Create a dataframe : </p>
  
  <pre><code>res &lt;- data.frame("ID" = c(1,2), "str" = c(21,15), "c" = c("a1","a2"), "s" = c("s1","s2"), "c1" = c(2,4), "c2" = c(6,8))
  </code></pre>
  
  <p>with values :</p>
  
  <pre><code>  ID str  c  s c1 c2
  1  1  21 a1 s1  2  6
  2  2  15 a2 s2  4  8
  </code></pre>
  
  <p>I'm attempting to create new column <code>total</code> with values 8 and 12 which are the totals for c1,c2 for rows with id 1,2</p>
  
  <p>Here attempting to use lapply in order to create the column : </p>
  
  <pre><code>lapply(res , sum(c('c1' , 'c2')))
  </code></pre>
  
  <p>but returns error : </p>
  
  <pre><code>Error in sum(c("c1", "c2")) : invalid 'type' (character) of argument
  </code></pre>
  
  <p>How to sum specific columns in a data frame ?</p>
  
  <p>Update : </p>
  
  <p>To gain understanding of apply functions I'm attempting to implement using lapply only.</p>