Bind multiple data.tables into one row-wise or col-wise.
bind_cols(..., .name_repair = "unique")
bind_rows(..., .id = NULL)
data.tables or data.frames to bind
Treatment of duplicate names. See ?vctrs::vec_as_names
for options/details.
If TRUE, an integer column is made as a group id
# Binding data together by row
df1 <- data.table(x = 1:3, y = 10:12)
df2 <- data.table(x = 4:6, y = 13:15)
df1 %>%
bind_rows(df2)
#> # A tidytable: 6 × 2
#> x y
#> <int> <int>
#> 1 1 10
#> 2 2 11
#> 3 3 12
#> 4 4 13
#> 5 5 14
#> 6 6 15
# Can pass a list of data.tables
df_list <- list(df1, df2)
bind_rows(df_list)
#> # A tidytable: 6 × 2
#> x y
#> <int> <int>
#> 1 1 10
#> 2 2 11
#> 3 3 12
#> 4 4 13
#> 5 5 14
#> 6 6 15
# Binding data together by column
df1 <- data.table(a = 1:3, b = 4:6)
df2 <- data.table(c = 7:9)
df1 %>%
bind_cols(df2)
#> # A tidytable: 3 × 3
#> a b c
#> <int> <int> <int>
#> 1 1 4 7
#> 2 2 5 8
#> 3 3 6 9
# Can pass a list of data frames
bind_cols(list(df1, df2))
#> # A tidytable: 3 × 3
#> a b c
#> <int> <int> <int>
#> 1 1 4 7
#> 2 2 5 8
#> 3 3 6 9