title: Extract previous day value from a time-series object in R
body: <p>I have time-series (<code>xts</code> formatted) power consumption data at 10 minutes rate  as</p>
  
  <pre><code>                      power 
  2015-08-01 00:00:00 101.22              
  2015-08-01 00:10:00 122.941                
  2015-08-01 00:20:00  67.596              
  2015-08-01 00:30:00 184.180       
  </code></pre>
  
  <p>Now I want to add 3 more columns to it as:</p>
  
  <ol>
  <li>Column # 2: "Prevday1" -  where "prevday1" will contain the power consumption readings of previous day at the same time. That is, if the current index is 5 August 2015, 1100 hours then "prevday1" should contain consumption of previous day at same time instant (4 August 2015, 1100 hours)</li>
  <li>Column # 3: "Prevday2" -  where "prevday2" will contain the power consumption readings of day before previous day at the same time instant</li>
  <li>column # 4: "previnstant1" -  where "previnstant1" will contain reading of previous time instant. In my case it will be power consumption before 10 minutes</li>
  </ol>
  
  <p>Somehow new <code>xts</code> object will be like</p>
  
  <pre><code>                  power       prevday1     prevday2   previnstant1
  2015-08-01 00:00:00 101.22       NA          NA          NA
  2015-08-01 00:10:00 122.941      :            :           :
  2015-08-01 00:20:00  67.596              
  2015-08-01 00:30:00 184.180   
         :
  </code></pre>
  
  <p>Now the question is how should I extract the values for columns 2, 3 and 4 from the historical <code>xts</code> object. I started with <code>.indexday</code> type of functions but could not get the values. Is there any specific function in <code>R</code> to extract these type of values using <code>xts</code> indexes?</p>