View source: R/iterative_join.R
iterative_join | R Documentation |
The *_join
functions (left_join
, inner_join
, etc.) only allow a
join between 2 datasets, but sometimes we deal with several datasets
that we have to join using the same identifiers.
iterative_join(obj, fun, by = NULL, ...)
obj |
A list where each element is a dataset. |
fun |
The join function ( |
by |
A character vector of variables to join by. |
... |
Other parameters passed onto methods. |
This function receives as input a list where each element is one of the datasets, and specifying the type of join and the variable/s of join, it performs the process iteratively.
A tibble.
# Fake Data
library(dplyr)
data1 <- data.frame( 'id' = sample(1:5, 10, replace = T ),'x1' = rnorm(10) )
data2 <- data.frame( 'id' = sample(1:5, 10, replace = T ),'x2' = rnorm(10) )
data3 <- data.frame( 'id' = sample(1:5, 10, replace = T ),'x3' = rnorm(10) )
data4 <- data.frame( 'id' = sample(1:5, 10, replace = T ),'x4' = rnorm(10) )
list_data <- list( data1, data2, data3, data4 )
iterative_join(list_data, left_join, 'id')
iterative_join(list_data, inner_join, 'id')
iterative_join(list_data, full_join, 'id')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.