df1 <- data.frame( stringsAsFactors=FALSE,
x=1:1000,
y=sample(LETTERS, size=1000, replace=TRUE)
)
df2 <- data.frame( stringsAsFactors=FALSE,
x=sample( 1:2000, size=2000, replace=TRUE ),
z=sample( letters, size=2000, replace=TRUE ),
q=sample( LETTERS, size=2000, replace=TRUE )
)
dMerged <- pMerge( df1, df2, by="x" )
stopifnot( all.equal( df1, dMerged[1:ncol(df1)] ) )
Run the code above in your browser using DataLab