[R] Interweaving of two datasets
John Kane
jrkrideau at inbox.com
Thu May 10 17:10:27 CEST 2012
I don't quite follow what you are doing. Here is what Rui was suggesting using your sample data
===================================================================
dat1 <- structure(list(name = structure(c(4L, 3L, 5L, 2L, 1L, 6L), .Label = c("Andy",
"Bruce", "Ella", "John", "Luna", "Morgana"), class = "factor"),
address = structure(c(2L, 4L, 1L, 3L, 2L, 4L), .Label = c("Kiev street",
"london road", "main avenue", "Rome street"), class = "factor"),
phone = c(2123L, 2342L, 454L, 56775L, 287678L, 39876L)), .Names = c("name",
"address", "phone"), class = "data.frame", row.names = c(NA,
-6L))
dat2 <- structure(list(name = structure(c(4L, 4L, 3L, 3L, 3L, 5L, 5L,
2L, 2L, 2L, 2L, 1L, 6L, 6L, 6L), .Label = c("Andy", "Bruce",
"Ella", "John", "Luna", "Morgana"), class = "factor"), request = structure(c(1L,
5L, 4L, 1L, 3L, 4L, 5L, 5L, 5L, 4L, 4L, 2L, 1L, 4L, 2L), .Label = c("book",
"cigarettes", "drink", "food", "paper"), class = "factor")), .Names = c("name",
"request"), class = "data.frame", row.names = c(NA, -15L))
mydata <- merge(dat1, dat2)
mydata
===================================================================
#If you need information about a variable in the merge try something like:
table(mydata$phone)
Is this of any help?
John Kane
Kingston ON Canada
> -----Original Message-----
> From: gloriaalbe1 at yahoo.it
> Sent: Thu, 10 May 2012 07:33:45 -0700 (PDT)
> To: r-help at r-project.org
> Subject: Re: [R] Interweaving of two datasets
>
> Hi Ruri, sorry for my vagueness. The problem is not the order.
>
> I tried to merge the datasets as you wrote. The result is that when I
> input:
>
> table(phone)
>
> The output is:
> 0
>
> And this happens for all the variables.
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Interweaving-of-two-datasets-tp4608505p4623672.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.
____________________________________________________________
GET FREE SMILEYS FOR YOUR IM & EMAIL - Learn more at http://www.inbox.com/smileys
Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and most webmails
More information about the R-help
mailing list