Description Usage Arguments Examples
This function will merge a data frame df2
'into' a
data frame df1
, preserving df1
as much as
possible in the merger. Hence I call this a 'preserving'
merge, or pMerge
.
1 |
df1 |
the data.frame which we are preserving |
df2 |
the data.frame we are merging into df1 |
by |
character; name of the variable we are merging over |
doCheck |
boolean; set this if you want to perform more extensive (but slower) error checking |
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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)] ) )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.