Skip to content

merge bug fix in R 2.15.0

2 messages · Stephanie M. Gogarten, Brian Ripley

#
I would like to add a vote for keeping blank suffixes in merge(), as I 
routinely use this functionality.  An example use case:

# using R 2.14.1
# d1 is some data that I've been working on for a while
d1 <- data.frame(a=letters[1:10], b=1:10)
# d2 is some new data from a collaborator.  I want to add one of these # 
columns to d1, and also check that the existing columns are consistent
d2 <- data.frame(a=letters[1:10], b=1:10, c=101:110)

# use blank suffix to avoid changing the column names of my
# original data frame
d3 <- merge(d1, d2, by="a", suffixes=c("", ".new"))
all(d3$b == d3$b.new)
# if this is FALSE, time to email collaborator
d3$b.new <- NULL

In real usage d1 would have many more columns than d2, so adding 
suffixes to d1 would be tedious to undo after the merge.

Stephanie Gogarten
Research Scientist, Biostatistics
University of Washington
On 3/19/12 4:00 AM, r-devel-request at r-project.org wrote:
5 days later
#
On Mon, 19 Mar 2012, Stephanie M. Gogarten wrote:

            
But you don't have a vote ....

An exception has been made for "" in R 2.15.0.  However, further cases 
of unintended results resulting from duplicate names using merge() 
have come to light, so there will be further restrictions imposed in 
future to protect users from failing to consider duplicate names.