Learn R Programming

listr (version 0.1.0)

list_bind: Bind list elements together.

Description

Bind list elements together.

Usage

list_bind(in_list, ..., what = "rows", name = NULL)

Value

A list with the selected elements bound together as specified.

Arguments

in_list

The list to work on.

...

A selection of elements to bind together.

what

Either 'rows' or 'cols'.

name

Optional name for the resulting element.

Details

The element to bind together must be compatible in the dimension you want to bind them together, if not there will either be an error or an unexpected result.

The `what` parameter specifies whether to call `rbind` or `cbind` on the selected elements.

Using `name` you can optionally specify a new name for the result. It will be in the position of the first selected element, while the other selected elements will be removed from the input list.

Examples

Run this code
dfl <- list(data.frame(idx = 1:20, y = rnorm(20)),
            data.frame(idx = 21:40, y = rnorm(20)),
            data.frame(idx = 41:60, y = rnorm(20)))
list_bind(dfl, 1, 2, 3)

Run the code above in your browser using DataLab