[R] Retain only those records from a dataframe that exist in another dataframe

2006-08-07 Thread Mark Na
Dear R community, I have two dataframes first and second which share a unique identifier. I wish to make a new dataframe third retaining only the rows in first which also occur in second. I have tried using merge but can't seem to figure it out. Any ideas? Thanks! Mark

Re: [R] Retain only those records from a dataframe that exist in another dataframe

2006-08-07 Thread Peter Dalgaard
Mark Na [EMAIL PROTECTED] writes: Dear R community, I have two dataframes first and second which share a unique identifier. I wish to make a new dataframe third retaining only the rows in first which also occur in second. I have tried using merge but can't seem to figure it out. Any

Re: [R] Retain only those records from a dataframe that exist in another dataframe

2006-08-07 Thread Marc Schwartz (via MN)
On Mon, 2006-08-07 at 14:05 -0600, Mark Na wrote: Dear R community, I have two dataframes first and second which share a unique identifier. I wish to make a new dataframe third retaining only the rows in first which also occur in second. I have tried using merge but can't seem to figure

Re: [R] Retain only those records from a dataframe that exist in another dataframe

2006-08-07 Thread Mark Na
Thanks Peter and Mark, the subset and %in% commands did the job. For future reference, or for others reading this message, the code I ended up using was: third - subset(first, ID %in% second$ID) Mark On 8/7/06, Marc Schwartz (via MN) [EMAIL PROTECTED] wrote: On Mon, 2006-08-07 at 14:05

Re: [R] Retain only those records from a dataframe that exist in another dataframe

2006-08-07 Thread Gabor Grothendieck
Although this is probably not directly applicable to this problem I might mention here that merge.zoo does support left and right joins and that handles problems similar to this. z3t, z3ft, z3tf and z3f below have times of both unioned, the times of z2, the times of z1 and the times of both z1