Re: [R] Merging two data set in R,

2010-08-25 Thread Danne Mora
try the following "merge" command. merge(A,B, by = intersect(names(A), names(B)), all.x=FALSE, all.y=FALSE) or merge(A,B, by = "ID", all.x=FALSE, all.y=FALSE) Dannemora On Wed, Aug 25, 2010 at 5:35 AM, Mangalani Peter Makananisa < pmakanan...@sars.gov.za> wrote: > Dear R Gurus, > > > > I am cur

Re: [R] Merging two data set in R,

2010-08-25 Thread Sarah Goslee
Almost. You'll need to handle the duplicate ID yourself since R has no way of knowing which one(s) to change to NA. As I already suggested, you can use unique() in conjunction with whatever logical rules you require for choosing those values. As I also already suggested, all.y and all.x are the op

Re: [R] Merging two data set in R,

2010-08-25 Thread Sarah Goslee
he intersection. > > Please help. > > -Original Message- > From: Sarah Goslee [mailto:sarah.gos...@gmail.com] > Sent: 25 August 2010 01:52 PM > To: Mangalani Peter Makananisa > Cc: r-help@r-project.org > Subject: Re: [R] Merging two data set in R, > > First you ne

Re: [R] Merging two data set in R,

2010-08-25 Thread Sarah Goslee
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 like? 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 r

[R] Merging two data set in R,

2010-08-25 Thread Mangalani Peter Makananisa
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 CB. 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