extract: Extraction from list

View source: R/Utils.R

extractR Documentation

Extraction from list

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

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

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 Oct. 21, 2023, 7:11 a.m.