Hi, #Without indices
xzoo<-zoo() x1zoo_f<-zoo(1:10,) cbind(xzoo,x1zoo_f) x1zoo_f 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 #With indices on one x1zoo_f<-zoo(1:5,1:10) > cbind(xzoo,x1zoo_f) x1zoo_f 1 1 2 2 3 3 4 4 5 5 6 1 7 2 8 3 9 4 10 5 #with a different index. Here, I get warning message. x1zoo_f<-zoo(1:5,c(5,6,8,11,13)) > cbind(xzoo,x1zoo_f) x1zoo_f 5 1 6 2 8 3 11 4 13 5 Warning message: In merge.zoo(..., all = all, fill = fill, suffixes = suffixes, retclass = "zoo", : Index vectors are of different classes: integer numeric I am using R 2.15. Don't know if you get warnings or not. A.K. ________________________________ From: jpm miao <miao...@gmail.com> To: R. Michael Weylandt <michael.weyla...@gmail.com> Cc: r-help <r-help@r-project.org>; smartpink...@yahoo.com Sent: Tuesday, July 31, 2012 3:40 AM Subject: Re: [R] How can I declare an empty zoo object? Hi Michael, 1. I try this xzoo <- zoo() and it does work. OK, I will read the reference you provide to find out why not to do so 2. How can I create an array of zoo objects? 3. Do you mean by "R's wisest virgil" Pat Burns' R Inferno? To Arun: Even when indices (dates) of two zoo object don't match, I can cbind them. It works for me! Thanks, Miao 2012/7/31 R. Michael Weylandt <michael.weyla...@gmail.com> On Mon, Jul 30, 2012 at 11:18 PM, jpm miao <miao...@gmail.com> wrote: >> Hi, >> >> I let xzoo be an empty object: >> >>> xzoo<-{} > >This sounds like the start of a bad idea.... > > >> >> >> and I have an existing zoo object x1zoo_f. I would like to combine >> the two to make a new zoo object, and continue doing so in a loop, >> which is not shown here. However, when I type >> >> >>> xzoo<-cbind(xzoo, x1zoo_f) > >Yep: the real answer is "don't do that." Since R is >copy-on-write+pass-by-reference and a few other nice things, this will >be painfully gut-wrenchingly paint-dryingly slow :-) Much better is to >make all your "x1zoo_f" objects and cbind them at once. > >The perils of this idea and the appropriate fixings thereof have been >discussed here there and everywhere, but I think Pat Burn's >presentation in "the R Inferno" is the best (and certainly the most >fun) -- it's a worthwhile read and, perhaps an even higher compliment, >a worthwhile re-read. > >Based on my rough memories of your recent posts, you won't understand >it all in the first pass (few do -- I certainly don't), but over time >you'll gain immensely from the work of one of R's wisest Virgils. > > >> >> >> An error message emerges >> >> >> Error in zoo(structure(x, dim = dim(x)), index(x), ...) : >> “x” : attempt to define invalid zoo object >> >> >> Is there any way to define an empty zoo object? >> > >For completeness, > >xzoo <- zoo() > >But like I said: don't do that. > >Cheers, >Michael > >> >> Thanks, >> >> >> Miao >> >> [[alternative HTML version deleted]] >> >> >> ______________________________________________ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.