Note that there are some explanatory texts on larger screens.

plurals
  1. POxts merge odd behaviour
    primarykey
    data
    text
    <p>I have 3 xts objects all of whose indicies are 'Date' objects:</p> <pre><code> &gt; a a 1995-01-03 1.76 1995-01-04 1.69 &gt; b b 1995-01-03 1.67 1995-01-04 1.63 &gt; c c 1995-01-03 1.795 1995-01-04 1.690 </code></pre> <p>To verify the indices are the same:</p> <pre><code> &gt; index(a) == index(b) [1] TRUE TRUE &gt; index(a) == index(c) [1] TRUE TRUE </code></pre> <p>Now I'm seeing this odd behaviour:</p> <pre><code> &gt; merge.xts(a,b) a b 1995-01-03 NA 1.67 1995-01-03 1.76 NA 1995-01-04 NA 1.63 1995-01-04 1.69 NA </code></pre> <p>While the following merge works fine:</p> <pre><code> &gt; merge.xts(a,c) a c 1995-01-03 1.76 1.795 1995-01-04 1.69 1.690 </code></pre> <p>I can't figure out what could possibly be going on here. Any idea?</p> <p>Update:</p> <pre><code> &gt; dput(a) structure(c(1.76, 1.69), .indexCLASS = "Date", .indexTZ = "", .CLASS = "xts", class = c("xts", "zoo"), index = structure(c(789168240, 789254580), tzone = "", tclass = "Date"), .Dim = c(2L, 1L), .Dimnames = list(NULL, "a")) &gt; dput(b) structure(c(1.67, 1.63), .indexCLASS = "Date", .indexTZ = "", .CLASS = "xts", class = c("xts", "zoo"), index = c(789109200, 789195600), .Dim = c(2L, 1L), .Dimnames = list( NULL, "b")) &gt; dput(c) structure(c(1.795, 1.69), .indexCLASS = "Date", .indexTZ = "", .CLASS = "xts", class = c("xts", "zoo"), index = c(789109200, 789195600), .Dim = c(2L, 1L), .Dimnames = list( NULL, "c")) </code></pre> <p>Indeed, the problem is that the indices are not identical (as verified by <code>.index(a) == .index(b)</code> ). Converting to numeric then recreating an xts and recomputing the dates with <code>asDate</code> fixed the problem.</p> <p>This objects were created from the <code>to.daily</code> method from xts.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload