title: Subtracting data in one column based on values in another column
body: <p>I want to subtract the values in the Temp column based on the values in the sensor column. Grouped by each date and location, I want to subtract Temp with the sensor value of 1 from Temp with a sensor value of 2. See data sample below.</p>
  
  <pre><code>date &lt;- c("2016-03-21","2016-03-21","2016-03-21","2016-03-21","2016-03-21","2016-03-21")
  location &lt;- c(1,1,2,2,3,3)
  sensor &lt;- c(1,16,1,16,1,16)
  Temp &lt;- c(35,34,45,42,46,47)
  df &lt;- data.frame(date,location,sensor,Temp)
  </code></pre>
  
  <p>This is my attempt at trying to do so using <code>dplyr</code>...</p>
  
  <pre><code>test &lt;- df %&gt;% group_by(date,location,sensor) %&gt;% lfMaxTemp$Temp["sensor"==1]-lfMaxTemp$Temp["sensor"==16]
  </code></pre>
  
  <p>This is the result I would like:</p>
  
  <pre><code>        date location diff
  1 2016-03-21        1    1
  2 2016-03-21        2    3
  3 2016-03-21        3   -1
  </code></pre>