Hi All, I am looking into merging 3 data sets I know how to do that by merging data1 with data2 and then merging the result with data 3. I was wondering if it can be done all at once so I tried, M<-merge(data1,data2,data3, by=?ID?) It does not work! Any ideas? -- View this message in context: http://www.nabble.com/merging-3-data-sets-at-once-tp17658873p17658873.html Sent from the R help mailing list archive at Nabble.com.
I could suggest merge(merge(data1,data2), data3). However, one problem I notice is that is assigns age=12 and gender=M to everyone with id=1, and so on. How are we to know that person with id=1 in data1 is the same person with id=1 in data2 and data3? Bill> Date: Wed, 4 Jun 2008 16:24:04 -0700> From: kjaja27@yahoo.com> To: r-help@r-project.org> Subject: [R] merging 3 data sets at once> > > Hi All,> > I am looking into merging 3 data sets I know how to do that by merging data1> with data2 and then merging the result with data 3. I was wondering if it> can be done all at once so I tried,> > M<-merge(data1,data2,data3, by=”ID”)> > It does not work!> Any ideas?> > > > -- > View this message in context: http://www.nabble.com/merging-3-data-sets-at-once-tp17658873p17658873.html> Sent from the R help mailing list archive at Nabble.com.> > ______________________________________________> 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. _________________________________________________________________ Instantly invite friends from Facebook and other social networks to join yo https://www.invite2messenger.net/im/?source=TXT_EML_WLH_InviteFriends [[alternative HTML version deleted]]
Using the built in dataset, women, here is a 3-way merge
on height using sqldf:
library(sqldf)
sqldf("select * from women u, women v, women w where u.height v.height and
v.height = w.height")
See home page at http://sqldf.googlecode.com for more info.
Its also possible in zoo if you can represent your data as zoo objects:
library(zoo)
w <- zoo(women$weight, women$height)
z <- merge(w, w, w) # zoo object
transform(as.data.frame(z), height = time(z)) # data frame
?zoo
?merge.zoo
Also three vignettes in package.
On Wed, Jun 4, 2008 at 7:24 PM, kayj <kjaja27 at yahoo.com>
wrote:>
> Hi All,
>
> I am looking into merging 3 data sets I know how to do that by merging
data1
> with data2 and then merging the result with data 3. I was wondering if it
> can be done all at once so I tried,
>
> M<-merge(data1,data2,data3, by="ID")
>
> It does not work!
> Any ideas?
>
>
>
> --
> View this message in context:
http://www.nabble.com/merging-3-data-sets-at-once-tp17658873p17658873.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>
By the way, I used age and gender as examples. Plus, I've seen something very similar posted a while ago. If the problem I listed isn't an issue, then that code will work. Best, Bill From: williampepe@hotmail.comTo: kjaja27@yahoo.com; r-help@r-project.orgSubject: RE: [R] merging 3 data sets at onceDate: Wed, 4 Jun 2008 20:50:34 -0400 I could suggest merge(merge(data1,data2), data3). However, one problem I notice is that is assigns age=12 and gender=M to everyone with id=1, and so on. How are we to know that person with id=1 in data1 is the same person with id=1 in data2 and data3? Bill> Date: Wed, 4 Jun 2008 16:24:04 -0700> From: kjaja27@yahoo.com> To: r-help@r-project.org> Subject: [R] merging 3 data sets at once> > > Hi All,> > I am looking into merging 3 data sets I know how to do that by merging data1> with data2 and then merging the result with data 3. I was wondering if it> can be done all at once so I tried,> > M<-merge(data1,data2,data3, by=”ID”)> > It does not work!> Any ideas?> > > > -- > View this message in context: http://www.nabble.com/merging-3-data-sets-at-once-tp17658873p17658873.html> Sent from the R help mailing list archive at Nabble.com.> > ______________________________________________> 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. Instantly invite friends from Facebook and other social networks to join you on Windows Live™ Messenger. Invite friends now! _________________________________________________________________ Now you can invite friends from Facebook and other groups to join you on Wi https://www.invite2messenger.net/im/?source=TXT_EML_WLH_AddNow_Now [[alternative HTML version deleted]]