From s.ritchie73 at gmail.com  Thu Feb 15 23:08:29 2018
From: s.ritchie73 at gmail.com (Scott Ritchie)
Date: Fri, 16 Feb 2018 09:08:29 +1100
Subject: [Rd] Duplicate column names created by base::merge() when by.x has
 the same name as a column in y
Message-ID: <CAO1VBV2WCJDNgmDdbomwqGVq-aNXnz4puuCNvnSCpJ1WzQOQdQ@mail.gmail.com>

Hi,

I was unable to find a bug report for this with a cursory search, but would
like clarification if this is intended or unavoidable behaviour:

```{r}
# Create example data.frames
parents <- data.frame(name=c("Sarah", "Max", "Qin", "Lex"),
                      sex=c("F", "M", "F", "M"),
                      age=c(41, 43, 36, 51))
children <- data.frame(parent=c("Sarah", "Max", "Qin"),
                       name=c("Oliver", "Sebastian", "Kai-lee"),
                       sex=c("M", "M", "F"),
                       age=c(5,8,7))

# Merge() creates a duplicated "name" column:
merge(parents, children, by.x = "name", by.y = "parent")
```

Output:
```
   name sex.x age.x      name sex.y age.y
1   Max     M    43 Sebastian     M     8
2   Qin     F    36   Kai-lee     F     7
3 Sarah     F    41    Oliver     M     5
Warning message:
In merge.data.frame(parents, children, by.x = "name", by.y = "parent") :
  column name ?name? is duplicated in the result
```

Kind Regards,

Scott Ritchie

	[[alternative HTML version deleted]]



[Rd] Duplicate column names created by base::merge() when by.x has the same name as a column in y
Scott Ritchie