Skip to contents

Combine data.frames that are in a list.

Usage

combine_dataframes(dataframes, by_var)

Arguments

dataframes

List of dataframes.

by_var

Variable to join by.

Value

A joined dataframe.

Examples

df1 <- data.frame(id = 1:3, value = c("A", "B", "C"))
df2 <- data.frame(id = 2:4, value = c("D", "E", "F"))
df3 <- data.frame(id = 1:4, value = c("G", "H", "I", "J"))
dataframes <- list(df1, df2, df3)
combine_dataframes(dataframes, by_var = "value")
#>    id.x value id.y id
#> 1     1     A   NA NA
#> 2     2     B   NA NA
#> 3     3     C   NA NA
#> 4    NA     D    2 NA
#> 5    NA     E    3 NA
#> 6    NA     F    4 NA
#> 7    NA     G   NA  1
#> 8    NA     H   NA  2
#> 9    NA     I   NA  3
#> 10   NA     J   NA  4