stableMerge {MIfuns} | R Documentation |
Merge Two Data Sets Without Altering Material from the Left Argument.
stableMerge(x, y)
x |
The main data.frame. |
y |
A second data.frame containing related information |
merge
is notoriously unpredictable, because it can add, drop, and
reorder rows, as well as reorder columns and recreate row names.
stableMerge
solves all that. It expects a primary data frame and
a secondary dataframe, and performs a 'stable' left join (all.x=TRUE,
(all.y=FALSE). Absence of extra arguments is by design, for integrity.
Keys are defined by common columns, and are repeatable in the primary,
but must be unique in the secondary dataframe. New columns in the
secondary frame are appended to the primary, supplying secondary info
by key match. No rows are added, or dropped, row/column order is
unaffected, and row names are preserved.
A dataframe with as many rows as nrow(x) but possibly more columns.
Tim Bergsma
#a nonsense example stableMerge(Theoph,BOD)