title: Recursive looping through xts
body: <p>I'm modelling the development of the orderbook over time. I have an initial orderbook shape in xts and then the subsequent depth updates also in xts:</p>
  
  <p>The initial orderbook shape looks as follows (all entries have the same time):</p>
  
  <pre><code>                            BID.price       size
  2014-02-11 23:59:42.494426  508.1000        10.0000000
  2014-02-11 23:59:42.494426  509.1200         8.0000000
  2014-02-11 23:59:42.494426  509.1000        10.0000000
  </code></pre>
  
  <p>and the subsequent depth udpates look as follows:</p>
  
  <pre><code>                           BID. price       size
  2014-02-12 04:57:51.191514 508.1000        -10.00000000
  2014-02-12 04:57:51.640302 514.0000         10.00000000
  </code></pre>
  
  <p>What I need to to is:</p>
  
  <p>1) for each row in updates, compare the price with the orderbook:</p>
  
  <p>1a) If the updates price level is in orderbook already, adjust the size accordingly, so the example above would look as follows:</p>
  
  <pre><code>                            BID.price       size
  2014-02-12 04:57:51.191514  509.1200         8.0000000
  2014-02-12 04:57:51.291514  509.1000        10.0000000
  </code></pre>
  
  <p>(the price level 508.10000 was deleted, and time was updated)</p>
  
  <p>1b) If the depth updates is not in orderbook yet, add new prise level with given size, so the example would looks like:</p>
  
  <pre><code>                            BID.price       size
  2014-02-12 04:57:51.640302  509.1200         8.0000000
  2014-02-12 04:57:51.640302  509.1000         10.0000000
  2014-02-12 04:57:51.640302  514.0000         10.00000000
  </code></pre>
  
  <p>(new price level of 514 was added and time was adjusted).</p>
  
  <p>Is there any convenient and fast way how to do such thing avoiding the for loop over depth updates xts?</p>
  
  <p>Thanks!</p>