hadley/plyr — Issue #65: join slow with match="all"
Author: otsaw
Created: 2011-10-31 12:54:18+00:00
State: open

I recently upgraded from plyr 1.4.x to 1.6 and subsequently to git head. The new match argument seems very slow with its default value "all". In the example below, there are no duplicate matches, but match="all" takes on my computer 22 seconds, compared almost zero for match="first".

library(plyr)
a = data.frame(x=1:3, y=1:3)
n = 2000
b = data.frame(x=1:n, y=1:n, z=1:n)
print(system.time(join(a, b, type="left", match="first")))
print(system.time(join(a, b, type="left", match="all")))

If for some algorithmic reason match="all" is bound to be significantly slower, perhaps you could consider making "first" the default match argument. I'd argue it's the more common use case anyway.