Learn R Programming

versioning (version 0.1.0)

pull_from_list: Safely pull an item from a list

Description

Indexing function for a list

Usage

pull_from_list(x, ..., fail_if_null = TRUE)

Arguments

x

List to pull items from

...

List indices to pull. Can be either numeric or (preferably) a character.

fail_if_null

(logical, default TRUE). Returns an informative error message if the list index is NULL. This function must always be named.

Details

Use the ... arguments to index the list. Not passing any ... arguments will return the entire list. The indexing will fail if either of two conditions are met:

  1. The index (which can be numeric or a key) does not exist in the list

  2. If the index exists but the value of the item is NULL, and fail_if_null is TRUE