iterative_join: Iterative Join

View source: R/iterative_join.R

iterative_joinR Documentation

Iterative Join

Description

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.

Usage

iterative_join(obj, fun, by = NULL, ...)

Arguments

obj

A list where each element is a dataset.

fun

The join function (left_join, inner_join, etc.).

by

A character vector of variables to join by.

...

Other parameters passed onto methods.

Details

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.

Value

A tibble.

Examples


# 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')

octmedina/ksnet documentation built on April 18, 2023, 3:34 p.m.