Hi, I have a quick question here. Lets say he has three data frames and he
needs to combine those three data frame using merge. Can we simply use
merge to join three data frames ? I remember I had some problem using merge
for more than two dataframes.

Thanks.


On Wed, Apr 17, 2013 at 1:05 AM, Farnoosh <farnoosh...@yahoo.com> wrote:

> Thanks a lot:)
>
> Sent from my iPad
>
> On Apr 16, 2013, at 10:15 PM, arun <smartpink...@yahoo.com> wrote:
>
> > Hi Farnoosh,
> > YOu can use either ?merge() or ?join()
> > DataA<- read.table(text="
> > ID     v1
> > 1     10
> > 2     1
> > 3     22
> > 4     15
> > 5     3
> > 6     6
> > 7     8
> > ",sep="",header=TRUE)
> >
> > DataB<- read.table(text="
> > ID v2
> > 2 yes
> > 5 no
> > 7 yes
> > ",sep="",header=TRUE,stringsAsFactors=FALSE)
> >
> > merge(DataA,DataB,by="ID",all.x=TRUE)
> > #  ID v1   v2
> > #1  1 10 <NA>
> > #2  2  1  yes
> > #3  3 22 <NA>
> > #4  4 15 <NA>
> > #5  5  3   no
> > #6  6  6 <NA>
> > #7  7  8  yes
> >  library(plyr)
> >  join(DataA,DataB,by="ID",type="left")
> > #  ID v1   v2
> > #1  1 10 <NA>
> > #2  2  1  yes
> > #3  3 22 <NA>
> > #4  4 15 <NA>
> > #5  5  3   no
> > #6  6  6 <NA>
> > #7  7  8  yes
> > A.K.
> >
> >
> >
> >
> >
> > ________________________________
> > From: farnoosh sheikhi <farnoosh...@yahoo.com>
> > To: "smartpink...@yahoo.com" <smartpink...@yahoo.com>
> > Sent: Wednesday, April 17, 2013 12:52 AM
> > Subject: Merge
> >
> >
> >
> > Hi Arun,
> >
> > I want to merge a data set with another data frame with 2 columns and
> keep the sample size of the DataA.
> >
> > DataA  DataB  DataCombine
> > ID v1  ID V2  ID v1 v2
> > 1 10  2 yes  1 10 NA
> > 2 1  5 no  2 1 yes
> > 3 22  7 yes  3 22 NA
> > 4 15     4 15 NA
> > 5 3     5 3 no
> > 6 6     6 6 NA
> > 7 8     7 8 yes
> >
> >
> > Thanks a lot for your help and time.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to