title: Converting an xts object to a useful data frame
body: <p>A dataframe named d contains this data:</p>
  
  <pre><code>timestamp,value
  "2013-06-02 00:00:00",70
  "2013-06-02 00:02:00",70
  "2013-06-02 00:07:00",60
  "2013-06-02 00:15:00",70
  "2013-06-02 00:12:00",60
  "2013-06-02 00:30:00",70
  "2013-06-02 00:45:00",70
  "2013-06-02 01:00:00",70
  </code></pre>
  
  <p>The code I have is:</p>
  
  <pre><code> d = read.csv(path, header=TRUE, sep=",")
   d2 &lt;- xts(x = d[c("value")], order.by = as.POSIXct(d[, "timestamp"], tz = "GMT", format = "%Y-%m-%d %H:%M:%S"))
  ends &lt;- endpoints(d2, on = "minutes", k = 15)
  d3   &lt;- period.apply(d2, ends, mean)
  </code></pre>
  
  <p>After that I want to convert the xts object to the dataframe and I am using this:</p>
  
  <pre><code>d3$timestamp = rownames(d3)
  rownames(d3) = NULL
  d3$timestamp = strptime(d3$timestamp, "%Y-%m-%d %H:%M:%S")
  </code></pre>
  
  <p>However in the last step it prints error to this:</p>
  
  <pre><code>Error in NextMethod(.Generic) : 
     number of items to replace is not a multiple of replacement length
  </code></pre>
  
  <p>As I observe typing d3 after the whole commands the object has this format of data:</p>
  
  <pre><code>                         timestamp
  2013-06-02 00:15:00        65
  2013-06-02 00:30:00        70
  2013-06-02 00:45:00        70
  2013-06-02 01:00:00        70
  </code></pre>
  
  <p>However in the column name it must have the name value and as the second column have the timestamp like <a href="https://stackoverflow.com/questions/11427434/how-to-create-a-variable-of-rownames/11427568#11427568">here</a>. What could be wrong?</p>
  
  <p>The right output must be this:</p>
  
  <pre><code>      value
          65  2013-06-02 00:15:00
          70  2013-06-02 00:30:00
          70  2013-06-02 00:45:00
          70  2013-06-02 01:00:00 
  </code></pre>