[R] Gaps on merging xts objects

eric ericstrom at aol.com
Sun Jun 10 18:22:30 CEST 2012


Looking for a little help figuring out what's driving gaps in data after
merging two xts objects (msci.m and x2). The merge statement I'm using is
...   y <-merge(x2,msci.m, all=FALSE). Here's info on the output , y:

head(y)
         t-bill     msci
Sep 1985  7.310  316.963
Mar 1986  6.560  463.471
Jun 1986  6.180  498.791
Jul 1987  6.200  778.898
Aug 1987  6.400  833.519
Nov 1987  5.690  704.726
Feb 1988  5.780  783.533
May 1988  6.730  813.289

tail(y)
Mar 2008  1.465 2039.001
Jun 2008  1.936 1990.710
Aug 2009  0.152 1506.642
Nov 2009  0.061 1573.659
Jan 2011  0.152 1730.912
Feb 2011  0.147 1791.900
May 2011  0.061 1772.492
Oct 2011  0.010 1538.103
Apr 2012  0.096 1549.291

Notice the gap between Sept 1985 and March 1986 for example. Or the missing
2010 data. Both x2 and msci.m are monthly data. Here's info about both those
objects:

> str(x2)
An ‘xts’ object from Dec 1984 to May 2012 containing:
  Data: num [1:330, 1] 8.14 8.06 8.69 8.71 8.15 7.49 7.33 7.48 7.31 7.31 ...
 - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr "x1.Close"
  Indexed by objects of class: [yearmon] TZ: 
  xts Attributes:  
List of 2
 $ tclass: chr "Date"
 $ tzone : chr ""
> str(msci.m)
An ‘xts’ object from Dec 1969 to May 2012 containing:
  Data: num [1:510, 1] 100 97.7 96.2 95.9 85.6 ...
 - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr "msci.Close"
  Indexed by objects of class: [yearmon] TZ: 
  xts Attributes:  
List of 2
 $ tclass: chr "Date"
 $ tzone : chr ""

> head(msci.m)
         msci.Close
Dec 1969    100.000
Jan 1970     97.655
Feb 1970     96.154
Mar 1970     95.857
Apr 1970     85.564
May 1970     79.005
> head(x2)
         x1.Close
Dec 1984     8.14
Jan 1985     8.06
Feb 1985     8.69
Mar 1985     8.71
Apr 1985     8.15
May 1985     7.49

tail(msci.m)
         msci.Close
Dec 2011   1445.066
Jan 2012   1521.751
Feb 2012   1601.262
Mar 2012   1582.660
Apr 2012   1549.291
May 2012   1363.978
> tail(x2)
         x1.Close
Dec 2011    0.025
Jan 2012    0.051
Feb 2012    0.117
Mar 2012    0.086
Apr 2012    0.096
May 2012    0.086

So how do I figure out what's driving the gaps ?



--
View this message in context: http://r.789695.n4.nabble.com/Gaps-on-merging-xts-objects-tp4632941.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list