Bind any number of data frames by row, making a longer result. Similar to `dplyr::bind_rows`, however, columns with same names but different data types would be coerced to a single proper data type.

bind_rows_dt(...)

Arguments

...

Data frames to combine. Each argument can either be a data frame, a list that could be a data frame, or a list of data frames. Columns are matched by name, and any missing columns will be filled with `NA`.

Value

data.table

See also

Examples


bind_rows_dt(iris[1:3,],iris[6:8,])
#>    Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#>           <num>       <num>        <num>       <num>  <fctr>
#> 1:          5.1         3.5          1.4         0.2  setosa
#> 2:          4.9         3.0          1.4         0.2  setosa
#> 3:          4.7         3.2          1.3         0.2  setosa
#> 4:          5.4         3.9          1.7         0.4  setosa
#> 5:          4.6         3.4          1.4         0.3  setosa
#> 6:          5.0         3.4          1.5         0.2  setosa

# data frames with same name but different type
# numeric data would be coerced to character data in this case
df1 <- data.frame(x = 1:2, y = letters[1:2])
df2 <- data.frame(x = 4:5, y = 1:2)
bind_rows_dt(df1, df2)
#>        x      y
#>    <int> <char>
#> 1:     1      a
#> 2:     2      b
#> 3:     4      1
#> 4:     5      2