• rbind_fill() [Deprecated] use rbind_fill_id() instead.

  • rbind_fill_id() [Experimental] Implements the common pattern of do.call(rbind, dfs) with data frame identifier and filling of missing values.

rbind_fill_id(..., .id = NULL, .fill = NA)

rbind_fill(..., .fill = NA)

Arguments

...

The dataframes. Either a list of data frames, or a comma-separated list of dataframes.

.id

Data frame identifier. If a comma-separated list of data frames is supplied, the labels are taken from the names of the objects. When a list of data frames is supplied, the labels are taken from the names of the list. If no names are found, a numeric sequence is used instead.

.fill

When row-binding, columns are matched by name, and any missing columns will be filled with NA Defaults to NA.

Value

A data frame.

Author

Tiago Olivoto tiagoolivoto@gmail.com

Examples

# \donttest{ (df1 <- data.frame(v1 = c(1, 2), v2 = c(2, 3)))
#> v1 v2 #> 1 1 2 #> 2 2 3
(df2 <- data.frame(v3 = c(4, 5)))
#> v3 #> 1 4 #> 2 5
rbind_fill_id(df1, df2)
#> v1 v2 v3 #> 1 1 2 NA #> 2 2 3 NA #> 3 NA NA 4 #> 4 NA NA 5
rbind_fill_id(df1, df2, .fill = ".", .id = "dfs")
#> dfs v1 v2 v3 #> 1 df1 1 2 . #> 2 df1 2 3 . #> 3 df2 . . 4 #> 4 df2 . . 5
# Named list list <- list(a = df1, b = df2) rbind_fill_id(list, .id = "dfs")
#> dfs v1 v2 v3 #> 1 a 1 2 NA #> 2 a 2 3 NA #> 3 b NA NA 4 #> 4 b NA NA 5
# Unnamed list list <- list(df1, df2) rbind_fill_id(list, .id = "dfs")
#> dfs v1 v2 v3 #> 1 1 1 2 NA #> 2 1 2 3 NA #> 3 2 NA NA 4 #> 4 2 NA NA 5
# }