[R] Merging two data set in R,
sarah.goslee at gmail.com
Wed Aug 25 14:08:23 CEST 2010
What do you want to happen when there are duplicates?
What happens to ID 1? 2? 3? in your desired output?
The all.x and all.y options might be of use.
On Wed, Aug 25, 2010 at 8:00 AM, Mangalani Peter Makananisa
<pmakananisa at sars.gov.za> wrote:
> I want to merge data set A and B, by merge(A,B, by = "ID"), however I am getting error massages, because the some ID's in A repeat themselves several time in data set B. Even if the ID's in B repeat themselves I want to be able to merge the two dataset and retrieve the intersection.
> Please help.
> -----Original Message-----
> From: Sarah Goslee [mailto:sarah.goslee at gmail.com]
> Sent: 25 August 2010 01:52 PM
> To: Mangalani Peter Makananisa
> Cc: r-help at r-project.org
> Subject: Re: [R] Merging two data set in R,
> First you need to clarify what you'd like to happen when the ID in B
> is not unique. What do you want the resulting dataframe to look
> Some possible answers involve using different options for merge() or
> using unique() to remove duplicates from B before merging. But
> at least to me, "merge or retrieve the common ones" isn't clear
> enough to be able to say which.
> On Wed, Aug 25, 2010 at 5:35 AM, Mangalani Peter Makananisa
> <pmakananisa at sars.gov.za> wrote:
>> Dear R Gurus,
>> I am currently working on the two dataset ( A and B), they both have the
>> same fields: ID , REGION, OFFICE, CSTART, CEND, NCYCLE, STATUS and
>> I want to merge the two data set by ID. The problem I have is that the
>> in data A, the ID's are unique. However in the data set B, the ID's are
>> not unique, thus some repeat themselves.
>> How do I the merge or retrieve the common ones?
>> Please advise.
>> Kind Regards
More information about the R-help