extract: Extraction from list

Description Usage Arguments Value Examples

View source: R/Utils.R

Description

Given a list of identical objects, extract the same index of each object. This can be used to extract the same column from a list of matrices, the same index from a list of vectors or the same element from a list of lists. Multiple indeces can be provided.

Usage

1
extract(l, index = 1, simplify = T)

Arguments

l

list of elements with identical structure.

index

numeric or character to be applied to each element of list. Logicals can also be used, but will not work well with lists of lists.

simplify

should the output be simplified?

Value

list, vector or matrix of extracted objects

Examples

1
2
3
4
example <- list(data.frame(A = "first dataframe", B = "second argument"),
    data.frame(A = "second dataframe", B = "second argument"))
#From each data.frame extract column A
extract(example,"A")

Alethere/SmoothDescent documentation built on Jan. 14, 2022, 9:40 p.m.