Re: [R] cbind giving NA's?

2011-10-24 Thread Joshua Ulrich
Note that this issue was raised on StackOverflow recently. http://stackoverflow.com/questions/7678090/xts-merge-odd-behaviour Here's the solution: index(a) - index(a) index(b) - index(b) merge(a,b) ZWD.UGX SCHB.Close 2010-03-31 NA 28.02 2010-04-01 7.6343 NA

[R] cbind giving NA's?

2011-08-26 Thread Hasan Diwan
I have two xts objects, call them a and b, and am trying to merge them... class(a) [1] xts zoo class(b) [1] xts zoo head(a) 2010-04-01 7.6343 2010-04-02 7.6343 2010-04-03 7.5458 2010-04-04 7.4532 2010-04-05 7.4040 2010-04-06 7.3317 head(b) 2010-04-01 568.80 2010-04-05 571.01

Re: [R] cbind giving NA's?

2011-08-26 Thread R. Michael Weylandt
Hmm, that's quite puzzling. I don't know but I'd willing to guess the time/date stamps on a,b are more different than the output is leading us to believe. My experience is that there's always more to a time/date object to trick us up than one would expect. If you could, dput() them so we can see

Re: [R] cbind giving NA's?

2011-08-26 Thread Hasan Diwan
On 26 August 2011 03:37, R. Michael Weylandt michael.weyla...@gmail.com wrote: If you could, dput() them so we can see everything about them. You also might see if merge() gives you more expected behavior Ok... dput(a) structure(c(7.6343, 7.6343, 7.5458, 7.4532, 7.404, 7.3317), class =

Re: [R] cbind giving NA's?

2011-08-26 Thread Petr PIKAL
Hi On 26 August 2011 03:37, R. Michael Weylandt michael.weyla...@gmail.com wrote: If you could, dput() them so we can see everything about them. You also might see if merge() gives you more expected behavior Ok... dput(a) structure(c(7.6343, 7.6343, 7.5458, 7.4532, 7.404,

Re: [R] cbind giving NA's?

2011-08-26 Thread Dennis Murphy
Hi: Try this: require('xts') merge.zoo(zoo(a), zoo(b), all = c(TRUE, TRUE)) ZWD.UGX SCHB.Close 2010-03-31 NA 28.02 2010-04-01 7.6343 NA 2010-04-02 7.6343 NA 2010-04-03 7.5458 NA 2010-04-04 7.4532 28.30 2010-04-05 7.4040 28.38

Re: [R] cbind giving NA's?

2011-08-26 Thread Petr PIKAL
I was rather too quick It has probably something to do with versions of zoo and xts after updating to zoo 1.7.4 and xts 0.8.2 I got with your examples merge(a,b) ZWD.UGX SCHB.Close 2010-04-01 NA 28.02 2010-04-01 7.6343 NA 2010-04-02 7.6343 NA 2010-04-03

Re: [R] cbind giving NA's?

2011-08-26 Thread R. Michael Weylandt
This seems to be the easiest way to handle the problem: a = xts(coredata(a), time(a)) b = xts(coredata(b), time(b)) merge(a,b) ZWD.UGX SCHB.Close 2010-03-31 NA 28.02 2010-04-01 7.6343 NA 2010-04-02 7.6343 NA 2010-04-03 7.5458 NA 2010-04-04