This function is essentially a wrapper for any of dplyr
's
mutate-joins (by default, a full_join).
The most typical use of this function is to merge designs with measures
data, or to use the collapse functionality to merge a list of dataframes
into a single dataframe. Merging is done by column names that match
between x
and y
.
Usage
merge_dfs(
x,
y = NULL,
by = NULL,
drop = FALSE,
collapse = FALSE,
names_to = NA,
join = "full",
warn_morerows = TRUE,
...
)
Arguments
- x
First data.frame, or list of data frames, to be joined
- y
Second data.frame, or list of data frames, to be joined
- by
A character vector of variables to join by, passed directly to the join function
- drop
Should only
complete_cases
of the resulting data.frame be returned?- collapse
A logical indicating whether x or y is a list containing data frames that should be merged together before being merged with the other
- names_to
Column name for where
names(x)
ornames(y)
will be entered in ifcollapse = TRUE
.If a value of
NA
thennames(x)
ornames(y)
will not be put into a column in the returned data.frame- join
Type of join used to merge
x
andy
. Options are 'full' (default), 'inner', 'left', and 'right'.A
full
join keeps all observations inx
andy
A
left
join keeps all observations inx
A
right
join keeps all observations iny
An
inner
join only keeps observations found in bothx
andy
(inner joins are not appropriate in most cases because observations are frequently dropped).
See full_join, left_join, right_join, or inner_join for more details
- warn_morerows
logical, should a warning be passed when the output has more rows than x and more rows than y?
- ...
Other arguments to pass to the underlying join function. See full_join, left_join, right_join, or inner_join for options.