[R-SIG-Finance] save XTS

zubin binabina at bellsouth.net
Tue Nov 3 00:57:50 CET 2009


yep, that was it.  loaded quantmod library, all is well.  thx

-zubin


J Ryan wrote:
> The fact that you see a class attribute is a red flag that you haven't 
> loaded the appropriate package, as Josh has also alluded to.
>
> This is due to the fact that R hasn't any methods to handle zoo or xts 
> natively, so you just see attributes. print.xts hides this normally.
>
> HTH
> Jeff
>
> Jeffrey A. Ryan
> jeffrey.ryan at insightalgo.com
>
> ia: insight algorithmics
> www.insightalgo.com
>
> On Nov 2, 2009, at 5:23 PM, Joshua Ulrich <josh.m.ulrich at gmail.com> 
> wrote:
>
>> Did you load xts via "library(xts)" before you tried to use the xts 
>> object?
>>
>> Best,
>> Josh
>> -- 
>> http://www.fosstrading.com
>>
>>
>>
>> On Mon, Nov 2, 2009 at 5:18 PM, zubin <binabina at bellsouth.net> wrote:
>>> Hello, have an XTS object, simply trying to save, but when i open the
>>> saved file and review the XTS object, its different, and most of the
>>> data does not exist.  How does one save an XTS object correctly?
>>>
>>> Found this link but no mention;
>>> http://old.nabble.com/write.xts%28%29-and-read.xts%28%29-td25613485.html 
>>>
>>>
>>>
>>> example:  XTS object called VDF
>>>  > str(vdf)
>>> An 'xts' object from 2009-10-16 09:30:02 to 2009-10-16 15:59:56 
>>> containing:
>>>  Data: num [1:2919, 1:9] 87.3 87.2 87.2 87.2 87.2 ...
>>>  - attr(*, "dimnames")=List of 2
>>>  ..$ : NULL
>>>  ..$ : chr [1:9] "FAS" "VIX" "UUP" "USO" ...
>>>  Indexed by objects of class: [POSIXt,POSIXct] TZ: GMT
>>>  xts Attributes:
>>>  NULL
>>>  > head(vdf)
>>>                      FAS   VIX  UUP   USO    GLD   HYG  term   
>>> spread   TNX
>>> 2009-10-16 09:30:02 87.26 21.72 22.5 39.88 102.74 85.99 4.214 
>>> 0.826827 3.443
>>> 2009-10-16 09:30:10 87.24 21.72 22.5 39.88 102.77 85.99 4.214 
>>> 0.826827 3.443
>>> 2009-10-16 09:30:17 87.23 21.72 22.5 39.88 102.74 85.99 4.214 
>>> 0.826827 3.443
>>> 2009-10-16 09:30:25 87.23 21.72 22.5 39.89 102.74 85.99 4.209 
>>> 0.826827 3.438
>>> 2009-10-16 09:30:33 87.23 21.72 22.5 39.90 102.74 85.99 4.209 
>>> 0.826827 3.438
>>> 2009-10-16 09:30:40 87.23 21.72 22.5 39.90 102.76 85.99 4.209 
>>> 0.826827 3.438
>>>
>>> I now save:
>>>  > save(vdf,file="vdf.Rdata")
>>>
>>> I then open up vdf.Rdata, very different and i lose data.
>>>
>>> str(vdf)
>>>  xts [1:2919, 1:9] 87.3 87.2 87.2 87.2 87.2 ...
>>>  - attr(*, "dimnames")=List of 2
>>>  ..$ : NULL
>>>  ..$ : chr [1:9] "FAS" "VIX" "UUP" "USO" ...
>>>  - attr(*, "index")= num [1:2919] 1.26e+09 1.26e+09 1.26e+09 1.26e+09
>>> 1.26e+09 ...
>>>  - attr(*, ".indexTZ")= Named chr "GMT"
>>>  ..- attr(*, "names")= chr "TZ"
>>>  - attr(*, ".indexCLASS")= chr [1:2] "POSIXt" "POSIXct"
>>>  - attr(*, "class")= chr [1:2] "xts" "zoo"
>>>
>>>  > head(vdf)
>>> [1] 87.26 87.24 87.23 87.23 87.23 87.23
>>>  >
>>>
>>>        [[alternative HTML version deleted]]
>>>
>>> _______________________________________________
>>> R-SIG-Finance at stat.math.ethz.ch mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>>> -- Subscriber-posting only.
>>> -- If you want to post, subscribe first.
>>>
>>
>> _______________________________________________
>> R-SIG-Finance at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> -- Subscriber-posting only.
>> -- If you want to post, subscribe first.
>



More information about the R-SIG-Finance mailing list