Skip to contents

Collect Elements of Sublists

Usage

collect(x, element, default = NULL)

Arguments

x

a list of lists

element

name of list element to be collected from each sublist of x

default

value to be returned for lists that do not have an element called element.

Examples

x <- list(
  list(a = 1, b = 2),
  list(c = 3, a = 4),
  list(d = 5, e = 6)
)

collect(x, "a")
#> [1] 1 4
collect(x, "a", default = 99)
#> [1]  1  4 99