[R-SIG-Finance] recommended zoo merge for multiple objects

Brian G. Peterson brian at braverock.com
Fri Oct 9 19:55:58 CEST 2009


zubin wrote:
> Thx!
>
> One question:  Will cbind use the time index?  I want to make sure 
> everything lines up, as i have lags in the data.
>

Yes, xts will use the time index for cbind, rbind, merge, etc.  I 
regularly use xts to line up irregular high frequency data.  xts has 
date and time-based subsetting which is very useful for financial time 
series.

As Josh has already pointed out, merge.zoo will take more than two 
objects to merge as well, but in my opinion you should be using xts 
anyway for most financial time series data.  I "fall back" to zoo when I 
need to make things that look more like data frames, or sometimes for 
loading data into R from poorly organized files.

Regards,

    - Brian
> Brian G. Peterson wrote:
>> zubin wrote:
>>> Hello, i have about 20 objects, each object is a zoo object, a 
>>> ticker symbol.
>>> I am using merge.zoo to merge 2 objects successfully and using 
>>> return class to create a data frame.  However it looks like 
>>> merge.zoo can only handle 2 objects.  What's the recommended 
>>> approach to merge multiple zoo objects by the time index into a data 
>>> frame?
>>>
>>> example of 2 objects:
>>>
>>> df <- merge.zoo(XLF,SPY,all=TRUE, retclass="data.frame")
>>> where XLF and SPY are zoo objects.
>>>
>>>   
>> Use cbind with xts.  xts extends zoo, and should be preferred for 
>> financial time series.
>>
>> Regards,
>>
>>  - Brian
>>


-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list