hadley/plyr — Issue #63: 'join(a, b, type="inner")' vs. 'merge(a, b)'
Author: d4b6
Created: 2011-10-23 22:35:26+00:00
State: open

`` is not equivalent to `` in plyr 1.6.
The discrepancy can be reproduced using `` on semi-real data of medium complexity.
The reproducible example below does not work in plyr 1.6, and returns an incorrect result in plyr 1.6_develop.

## Reproducible example
1. download foo.csv at https://gist.github.com/1282106
2. run the following code using the development version (as of Oct 12, 2011) of plyr 1.6:

````
library(plyr)
foo <- read.csv("foo.csv") # 1000 unique records, no duplicates
nrow(join(foo, foo, type="inner")) # returns 1240 rows (incorrect result)
nrow(merge(foo, foo)) # returns 1000 rows (correct result)
````

## Notes:
The order of the columns affects the result:

````
library(plyr)
foo <- read.csv("foo.csv") # 1000 unique records, no duplicates
foo <- foo[ ,c(2:11,1)] # moving the first column to the end of the data.frame
nrow(join(foo, foo, type="inner")) # returns 1000 rows (correct result)
nrow(merge(foo, foo)) # returns 1000 rows (correct result)
````