title: loop through RasterBrick to calculate differences between sequential layers
body: <p>I have a large <code>RasterBrick</code> object containing a time series of raster layers representing biomass at each time interval (irregular).  What I need is a time series of the differences in biomass between two consecutive time periods (<code>difference in biomass = current biomass layer - last weeks biomass layer</code>). 
  My thoughts have been to use a loop or one of the apply functions to go through the the <code>RasterBrick</code> and for each <code>RasterLayer</code> apply the function of subtraction with the one earlier in the time series. The <code>RasterBrick</code> is ordered so the actual time stamps are not necessarily important. I have tried to find examples but have failed to make progress. Any pointers would be very appreciated.</p>
  
  <p>I'm providing a quick example of my situation in the following:</p>
  
  <pre><code>library(raster)
  </code></pre>
  
  <p>Random set of 10 raster layers, into RasterStack</p>
  
  <pre><code>r &lt;- raster(ncol=10, nrow=10)
  ;b &lt;- brick( sapply(1:10, function(i) setValues(r, rnorm(ncell(r), i, 3))))
  </code></pre>
  
  <p>Now I need a <code>RasterBrick</code> containing 9 layers with the results for </p>
  
  <blockquote>
    <p>difference in biomass = current biomass layer - last weeks biomass layer.</p>
  </blockquote>