An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20091009/ed04de80/attachment.pl>
recommended zoo merge for multiple objects
6 messages · zubin, Joshua Ulrich, Brian G. Peterson +1 more
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
Thx! One question: Will cbind use the time index? I want to make sure everything lines up, as i have lags in the data.
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
On Fri, Oct 9, 2009 at 12:43 PM, zubin <binabina at bellsouth.net> 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?
How did you conclude merge.zoo can only handle 2 objects? Read ?merge.zoo...
Arguments:
...: two or more objects, usually of class '"zoo"'.
Best,
Josh
--
http://www.fosstrading.com
example of 2 objects: df <- merge.zoo(XLF,SPY,all=TRUE, retclass="data.frame") where XLF and SPY are zoo objects. ? ? ? ?[[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.
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
merge.zoo can handle any number of zoo objects. There is *no* limitation to two objects. There are examples in the examples section at the end of ?merge.zoo
On Fri, Oct 9, 2009 at 1:43 PM, zubin <binabina at bellsouth.net> 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. ? ? ? ?[[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.