I actually have an identical question as to topic:
Keeping Character Types/Names in xts object in R
However, the question doesn't seem to have been resolved, and whether or not the original poster was able to solve the issue is unknown so I thought I should ask it again and hopefully obtain an answer.
I am working with a data table and I would like to convert this data table to an xts object. In my code I use the function as.xts()
to convert a data table object to an xts object, and when this happens the xts package drops all non-numeric columns and turns the data table into an xts object/matrix.
Now, there is a column in the data table object which is filled with names, and I would like to prevent xts from dropping this column when I convert the data table to an xts object. Is this possible?
xts_obj<-xts(x=some_mat,order_by=TIME, attr_name=dt$name)
. You can go through the chat discussion on that thread and see if it serves your purpose. – tushaRas.xts()
function then it will automatically drop all columns with non-numeric data types in them, so I'm looking for a way to keep them. I should note that I am looking to specifically use theas.xts()
function since it is much faster at converting objects compared to thexts()
function, and since I am working with extremely large objects I basically need all the speed I can get – NotsurewhatImdoingxts()
may work it does seem to be much, much slower. I ran it over a smaller dataset than what I'm currently using and it took a much longer time to perform the conversion compared toas.xts()
, I'm going to keep playing around with it a bit more and hope I can knock the time down more though – NotsurewhatImdoing