extractSubList
From BBmisc v1.10
by Bernd Bischl
Extracts a named element from a list of lists.
Extracts a named element from a list of lists.
Usage
extractSubList(xs, element, element.value, simplify = TRUE, use.names = TRUE)
Arguments
 xs
 [
list
] A list of named lists.  element
 [
character
] Name of element(s) to extract from the list elements ofxs
. What happens is this:x$el1$el2....
.  element.value
 [any]
If given,
vapply
is used and this argument is passed toFUN.VALUE
. Note that even for repeated indexing (if length(element) > 1) you only pass one value here which refers to the data type of the final result.  simplify
 [
logical(1)
 character(1)] IfFALSE
lapply
is used, otherwisesapply
. If “cols”, we expect the elements to be vectors of the same length and they are arranged as the columns of the resulting matrix. If “rows”, likewise, but rows of the resulting matrix. Default isTRUE
.  use.names
 [
logical(1)
] IfTRUE
andxs
is named, the result is named asxs
, otherwise the result is unnamed. Default isTRUE
.
Value

[
list
 simplified vector
 matrix
]. See above.
Examples
xs = list(list(a = 1, b = 2), list(a = 5, b = 7))
extractSubList(xs, "a")
extractSubList(xs, "a", simplify = FALSE)
Community examples
Looks like there are no examples yet.