metan (version 1.15.0)

utils_bind: Helper function for binding data

Description

  • 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.

Usage

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.

Examples

Run this code
# NOT RUN {
(df1 <- data.frame(v1 = c(1, 2), v2 = c(2, 3)))
(df2 <- data.frame(v3 = c(4, 5)))
rbind_fill_id(df1, df2)
rbind_fill_id(df1, df2,
             .fill = ".",
             .id = "dfs")

# Named list
list <- list(a = df1, b = df2)
rbind_fill_id(list, .id = "dfs")

# Unnamed list
list <- list(df1, df2)
rbind_fill_id(list, .id = "dfs")

# }
# NOT RUN {
# }

Run the code above in your browser using DataLab