1

I pull stock information from quantmod and it returns a xts object, where the index is the date that each row's data corresponds to. How can I convert the index into a column? I attached a screenshot of the data frame's first 6 rows.

index column has dates

EDIT: Different than How can I change XTS to data.frame and keep Index? because this question is from the prospective of a user who think the data is stored in a data.frame. Potentially useful question for the uninformed or novice.

Joshua Ulrich
  • 173,410
  • 32
  • 338
  • 418
matt-s
  • 11
  • 4
  • Data retrieved through `quantmod` is usually of class `xts`, which is not your normal dataframe. Read up on `xts` objects in the `xts` package vignette, available [here](https://cran.r-project.org/web/packages/xts/vignettes/xts.pdf). – DanY Oct 03 '18 at 18:05
  • 1
    @DanY Thank you so much. Your post lead me to this post that had the answer. https://stackoverflow.com/questions/3386850/how-can-i-change-xts-to-data-frame-and-keep-index-in-r – matt-s Oct 03 '18 at 18:43
  • I just added [an answer to the linked question](https://stackoverflow.com/a/52678996/271616) that will hopefully help new users. – Joshua Ulrich Oct 06 '18 at 12:22

0 Answers0