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
On 05/07/2013 04:33 PM, jpm miao wrote:
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
Not sure whether this really helps you but at least it works for your sample:
d3 - merge( d1, d2, by = c( a, b ) )
d3
Either d1$a and d2$a are always the same, or they are not.
If they are already the same, you can either omit one of them in the merge:
merge(d1, d2[,-2], by=b)
or you can use a set of columns for your by:
merge(d1,d2, by=c(a,b))
If the a columns are distinct, then at least one of them needs a
If the a columns are distinct, then at least one of them needs a new name
in the
merged table, and the simplest option is to rename the columns appropriately
in d1 and
d2 (since they apparently represent different data anyway).
You can also use the 'suffixes. argument to merge to control
5 matches
Mail list logo