title: Subtract one row from another row in df
body: <p>I have DF which looks like </p>
  
  <pre><code>DF
  Nrow  a   b    c   d
  1     0.1 0.2 0.3 0.4 
  2      2   3   4   5
  3      7   8   9   10
  </code></pre>
  
  <p>I want to subtract row 1 from row 2 and row 3.</p>
  
  <p>How can i do it ?
  Thank you for any tips.</p>
  
  <p><strong>Updates</strong> </p>
  
  <p>I saw this code: <a href="https://stackoverflow.com/questions/35781173/within-group-differences-from-group-member">within-group differences from group member</a>, and tried it as well.</p>
  
  <p>Edited my data: </p>
  
  <p><code>newdf &lt;- df[!is.na(S[,1]),]</code> ## df had NA values which was interfering with analysis, so I removed them. </p>
  
  <p><code>df &lt;- data.frame(treatment = rep(c('','baseline', 'treatment 1', 'treatment 2'), times=372),S[c(1:258)])</code> </p>
  
  <p><code>A &lt;- df %&gt;%
    mutate_each(funs(. - .[treatment=="baseline"]), -treatment) %&gt;%
    filter(treatment!="baseline")</code>  ##have multiple columns for which I would like to calculate row-wise change</p>
  
  <p><code>View(A)</code></p>
  
  <p>However, now I thought to get correct results (or absolute change, i.e.  row 2 - row 1), but the values are different from what I can calculate manually. Any thoughts? </p>
  
  <p>Thanks!</p>
  
  <p><strong>Answers 11.03.2016</strong> </p>
  
  <p><a href="https://stackoverflow.com/questions/35741538/2-y-axes-plot-with-absolute-relative-change-in-r-with-answers">2-y Axes Plot with calculated absolute &amp; relative Change in R</a></p>