merge_mult: Merge Multiple Data Frames

Description Usage Arguments Value Examples

View source: R/merge_mult.R

Description

Merge Multiple Data Frames

Usage

1
merge_mult(..., f, by, suffixes)

Arguments

...

data frames to be merged or one list of all data frames to be merged

f

merge function, valid options are dplyr::inner_join, dplyr::left_join, dplyr::right_join, dplyr::full_join, dplyr::semi_join, dplyr::anti_join, base::merge (default options)

by

vector of shared column names to merge on or list of vectors where each element of list refers to the by value for the ith merge

suffixes

vector specifying suffixes to be used for making unique the names of columns in the result which are not used for merging

Value

A data frame

Examples

1
2
3
4
5
6
7
8
9
# generate more random data
y1 <- data.frame(id = rep(1:5, 3), val = rnorm(15))
y2 <- data.frame(id = 1:15, id2 = rep(c("A", "B", "C"), 5), est = rnorm(15))
y3 <- data.frame(id = 1:15, id2 = rep(c("A", "B", "C"), 5), var = runif(15))

# merge by various attributes
merge_mult(y1, y2, y3, f = dplyr::inner_join, by = list("id", c("id", "id2")), suffixes = letters[1:3])
# equivalent to:
merge(y1, y2, by = "id") %>% merge(y3, by = c("id", "id2"))

jennguyen1/jn.general documentation built on March 20, 2018, 4:26 a.m.