Learn R Programming

listr (version 0.1.0)

list_select: Select parts of a list.

Description

Select parts of a list.

Usage

list_select(in_list, ...)

Value

A list of the selected elements.

Arguments

in_list

The list to select from.

...

The selection, can both be names and numeric positions.

Details

`list_select()` lets you select parts of a list either by position or by name. Names can be supplied as bare variable names and do not need to be supplied as strings or otherwise be quoted.

Elements are returned in the order they are given, this is useful if you want to reorder elements in a list. You can also rename while selecting, writing your selection like `new_name = old_name`.

Examples

Run this code
my_list <- list(a = c(1, 2), b = c(3, 4), c(5, 6))
list_select(my_list, a, 3)

Run the code above in your browser using DataLab