Skip to contents

A general function that takes a list of data.frames and returns a single and combines them into a single object. It will use the fastest method available. In order this is collapse::rowbind(), data.table::rbindlist(), vctrs::list_unchop(), then do.call(rbind.data.frame, x).

Usage

rbind_results(x, call = rlang::current_env(), .ptype = data.frame())

Arguments

x

a list where each element is a data.frame or NULL.

call

The execution environment of a currently running function, e.g. call = caller_env(). The corresponding function call is retrieved and mentioned in error messages as the source of the error.

You only need to supply call when throwing a condition from a helper function which wouldn't be relevant to mention in the message.

Can also be NULL or a defused function call to respectively not display any call or hard-code a code to display.

For more information about error calls, see Including function calls in error messages.

.ptype

currently unused. Reserved for a future release.

Value

see details.

Details

If all items in the list are data.frames, then the result will be a data.frame. If all elements are an sf object, then the result will be an sf object. If the items are mixed, the result will be a data.frame.

If any items are NULL, then an attribute null_elements will be attached to the result. The attribute is an integer vector of the indices that were NULL.

Examples


x <- head(iris)
res <- rbind_results(list(x, NULL, x))
attr(res, "null_elements")
#> [1] 2