extract_list: Extract Data Accumulated in a List

Description Usage Arguments Value Examples

View source: R/extract_list.R

Description

Loops through an iterative list and rearranges data structures. Accumulates structures of the same name into a subsetted list which can be accessed using $.
See is_iterative_list to see what qualifies.

Usage

1
extract_list(l, rbind = TRUE, recursive = TRUE)

Arguments

l

a list

rbind

logical; if TRUE rbinds/stacks all extracted elements into a data.table (if they are data frames); else they are returned as lists. Elements that are not data frames are returned as lists

recursive

logical; if TRUE extraction applied to list components of x

Value

a list

Examples

1
2
3
4
5
6
7
x <- purrr::rerun(3, 
  WI = list(a = matrix(1:6, nrow = 2), b = data.frame(i = 1:10, j = 1:10)),
  MN = list(cold = list(blue = runif(5), red = runif(15)), hot = rnorm(3)),
  CA = LETTERS
)
lst <- extract_list(x)
lst$MN$cold$red

jnguyen92/jn.general documentation built on April 3, 2020, 6:18 a.m.