Hi everyone,

I have the following call to the merge() function. How does one
prevent duplicate columns in the resulting data frame that the 2
parent data frames have in common but are not true key or "by"
variables?


data3<-merge(data1,data2,by="id")
data3

id total.x total.y balance
1 78  78 90
2 91  91 63
3 74  74 57
4 89  89 58
5 90  90 27


In this example, total is not a true key or "by" variable that
uniquely identifies rows suitable for matching purposes, but instead
just happens to be common to both sets.

In reality, I have hundreds for these "in common" variables, so I need
a solution that is tractable for a large number of "in common"
columns.

Thanks!

Dan

______________________________________________
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