<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    Here,<br>
    <br>
    you will find attached data used to illustrate the issue.<br>
    here is the code used as well<br>
    <br>
    #reading file<br>
    t1=read.csv("AUDJPY.csv", sep=";")<br>
    rownames(t1)<-t1[,"Index"];t1<-t1[,-1]<br>
    #constructing xts object<br>
    t1<-as.xts(t1,tzone="America/New_York", src="csv",
    updated=Sys.time())<br>
    <br>
    t2=read.csv("CHFJPY.csv", sep=";")<br>
    rownames(t2)<-t2[,"Index"];t2<-t2[,-1]<br>
    t2<-as.xts(t2,tzone="America/New_York", src="csv",
    updated=Sys.time())<br>
    <br>
    # requires quantmod<br>
    library(quantmod)<br>
    <br>
    #constructing daily close series<br>
    t1<-Cl(to.daily(t1))<br>
    t2<-Cl(to.daily(t2))<br>
    <br>
    #trying to merge<br>
    merge(t1,t2)<br>
    <br>
    #......and result....sadly...is<br>
    > merge(t1,t2)<br>
               t1.Close t2.Close<br>
    2007-01-02          NA       97.87<br>
    2007-01-02       94.59          NA<br>
    2007-01-03       94.38       97.32<br>
    2007-01-04       92.55       96.04<br>
    2007-01-05          NA       95.97<br>
    2007-01-05       92.37          NA<br>
    2007-01-07          NA       95.69<br>
    2007-01-07       92.23          NA<br>
    2007-01-08       92.89       96.23<br>
    <br>
    <br>
    <br>
    On 10/12/2010 10:04, Mark Breman wrote:
    <blockquote
      cite="mid:AANLkTik64YcnA9_of7qA7K+p21X+mRnCk_jSMdg-PaTu@mail.gmail.com"
      type="cite">Hi Anass,
      <div><br>
      </div>
      <div>Could it be the series have a (invisible) different time
        part, or the timezone is different.</div>
      <div><br>
      </div>
      <div>Regards,</div>
      <div><br>
      </div>
      <div>-Mark-<br>
        <br>
        <div class="gmail_quote">2010/12/10 Anass Mouhsine <span
            dir="ltr"><<a moz-do-not-send="true"
              href="mailto:anass.mouhsine@gmail.com">anass.mouhsine@gmail.com</a>></span><br>
          <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
            0.8ex; border-left: 1px solid rgb(204, 204, 204);
            padding-left: 1ex;">Hi all,<br>
            <br>
            I encountered a weird behaviour of merge function while
            using it with xts objects.<br>
            I have multiple xts objects (10 timeseries) that I want to
            merge in order to conduct a multivariate analysis.<br>
            Here is an example with only two timeseries<br>
            <br>
            #Let us define the time series<br>
            > t1<br>
                                                  Close<br>
            2007-01-02                  97.87<br>
            2007-01-03                  97.32<br>
            2007-01-04                  96.04<br>
            2007-01-05                  95.97<br>
            2007-01-07                  95.69<br>
            2007-01-08                  96.23<br>
            > t2<br>
                                                  Close<br>
            2007-01-02                  94.59<br>
            2007-01-03                  94.38<br>
            2007-01-04                  92.55<br>
            2007-01-05                  92.37<br>
            2007-01-07                  92.23<br>
            2007-01-08                  92.89<br>
            > c(class(t1),class(t2))<br>
            [1] "xts" "zoo" "xts" "zoo"<br>
            <br>
            #I do the merge using merge.xts<br>
            > t<-merge(t1,t2)<br>
            > t<br>
                                                  Close                
            Close<br>
            2007-01-02                  97.87                     NA<br>
            2007-01-02                     NA                  94.59<br>
            2007-01-03                  97.32                  94.38<br>
            2007-01-04                  96.04                  92.55<br>
            2007-01-05                  95.97                     NA<br>
            2007-01-05                     NA                  92.37<br>
            2007-01-07                  95.69                     NA<br>
            2007-01-07                     NA                  92.23<br>
            2007-01-08                  96.23                  92.89<br>
            <br>
            # I don't see where the problem lays since both xts objects
            have the same index<br>
            > index(t1)<br>
            [1] "2007-01-02" "2007-01-03" "2007-01-04" "2007-01-05"
            "2007-01-07" "2007-01-08"<br>
            > index(t2)<br>
            [1] "2007-01-02" "2007-01-03" "2007-01-04" "2007-01-05"
            "2007-01-07" "2007-01-08"<br>
            <br>
            # I tried using join but with no satisfying result<br>
            >t<-merge(head(t1),head(t2),join='inner')<br>
            > t<br>
                      CHFJPY..2007.....Close AUDJPY..2007.....Close<br>
            2007-01-03                  97.32                  94.38<br>
            2007-01-04                  96.04                  92.55<br>
            2007-01-08                  96.23                  92.89<br>
            <br>
            I am really out of tricks here :-[ .<br>
            <br>
            So if someone is kind enough as to point me towards the
            right direction, it would make my day.<br>
            <br>
            Thx in advance,<br>
            <br>
            Anass<br>
            <br>
            _______________________________________________<br>
            <a moz-do-not-send="true"
              href="mailto:R-SIG-Finance@r-project.org" target="_blank">R-SIG-Finance@r-project.org</a>
            mailing list<br>
            <a moz-do-not-send="true"
              href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance"
              target="_blank">https://stat.ethz.ch/mailman/listinfo/r-sig-finance</a><br>
            -- Subscriber-posting only. If you want to post, subscribe
            first.<br>
            -- Also note that this is not the r-help list where general
            R questions should go.<br>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>