Hi,
From time to time I merge two dataframes with possibly a common field.
Then the common field is no longer present,but what are present fieldname.x
and fieldname.y. How can I fix the problem so that I can still call by the
orignal fieldname? If you don't understand my problem, please see the
example below.
Thanks
Miao
> d1
a b c
1 1 4 5
2 2 5 6
3 3 6 7
> d2
d a f b
1 6 1 8 4
2 7 2 9 5
3 8 3 10 6
> d3<-merge(d1, d2, by="b")
> d3
b a.x c d a.y f
1 4 1 5 6 1 8
2 5 2 6 7 2 9
3 6 3 7 8 3 10
> d3["a"]
Error in `[.data.frame`(d3, "a") : undefined columns selected
> d3["a.x"]
a.x
1 1
2 2
3 3
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.