Actually, this one line code give what you want even if l_xts_one and l_xts_two have different lengths

na.omit (ifelse(l_xts_one[,1] == l_xts_two[,1], l_xts_one[,1],NA))
 

--- On Mon, 1/23/12, Michael <comtech.usa@gmail.com> wrote:

From: Michael <comtech.usa@gmail.com>
Subject: Re: [R-SIG-Finance] How do I intersecttwo time series?
To: "Brian G. Peterson" <brian@braverock.com>
Cc: "r-sig-finance" <r-sig-finance@stat.math.ethz.ch>
Date: Monday, January 23, 2012, 6:58 PM

Yes, but merge creates a bunch of "NA"s ... and we are not merging but
doing "intersections"?

I cannot seem to find a way to use "merge" to do "intersections"...

I have searched/googled numerous times...

Maybe there is something I am missing and a trick?

Thanks again!

On Mon, Jan 23, 2012 at 6:47 PM, Brian G. Peterson <brian@braverock.com>wrote:

> I will repeat my earlier advice:
>
> ?merge
>
>
>
>
> On Mon, 2012-01-23 at 17:53 -0600, Michael wrote:
> > Oh I forgot one thing:
> >
> > xts_one and xts_two are not neccessarily the same length...
> >
> > In effect, I was looking for a time series set-operation "intersect"....
> >
> > Thank you!
> >
> > On Mon, Jan 23, 2012 at 12:35 PM, Jun Zhu <junzhu98@yahoo.com> wrote:
> >
> > >   Assume you are testing the first column
> > >
> > > l_result <- ifelse(l_xts_one[,1] == l_xts_two[,1], l_xts_one[,1],NA)
> > >
> > >
> > >
> > >
> > > --- On *Mon, 1/23/12, Brian G. Peterson <brian@braverock.com>* wrote:
> > >
> > >
> > > From: Brian G. Peterson <brian@braverock.com>
> > > Subject: Re: [R-SIG-Finance] How do I intersecttwo time series?
> > > To: "Michael" <comtech.usa@gmail.com>
> > > Cc: "r-sig-finance" <r-sig-finance@stat.math.ethz.ch>
> > > Date: Monday, January 23, 2012, 8:25 AM
> > >
> > >   On Mon, 2012-01-23 at 08:06 -0600, Michael wrote:
> > > > I have two xts objects...and they have coulmns with the same
> names.ie
> > > > their column represent the same variables.
> > > >
> > > > The only difference is that the values in the rows may be different.
> > > > At
> > > > precisely the same timestamps the observations can be exactly the
> > > > same.
> > > >
> > > > How do I find the intersection of these two time series ie the rows
> > > > where
> > > > the observations are identical including the time stamps?
> > > >
> > > > How do I find intersection where a few specified coulmns are
> identical
> > > > including the time stamps?
> > > >
> > > > Thanks a lot!
> > >
> > > ?merge
> > >
> > > ?ifelse
> > >
> > > merge is amply covered in the xts documentation, and ifelse is covered
> > > in many write-ups on vectorized operations in R.
> > >
> > > _______________________________________________
> > > R-SIG-Finance@r-project.org<
> http://mc/compose?to=R-SIG-Finance@r-project.org>mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > > -- Subscriber-posting only. If you want to post, subscribe first.
> > > -- Also note that this is not the r-help list where general R questions
> > > should go.
> > >
> > >
> >
> >       [[alternative HTML version deleted]]
>  >
> > _______________________________________________
> > R-SIG-Finance@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > -- Subscriber-posting only. If you want to post, subscribe first.
> > -- Also note that this is not the r-help list where general R questions
> should go.
>
> --
> Brian G. Peterson
> http://braverock.com/brian/
> Ph: 773-459-4973
> IM: bgpbraverock
>
>

    [[alternative HTML version deleted]]

_______________________________________________
R-SIG-Finance@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.

	[[alternative HTML version deleted]]

