extractSubList {BBmisc} | R Documentation |
Extracts a named element from a list of lists.
Description
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 of xs .
What happens is this: x$el1$el2.... .
|
element.value |
[any]
If given, vapply is used and this argument is passed to FUN.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)]
If FALSE lapply is used, otherwise sapply .
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 is TRUE .
|
use.names |
[logical(1) ]
If TRUE and xs is named, the result is named as xs ,
otherwise the result is unnamed.
Default is TRUE .
|
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)
[Package
BBmisc version 1.13
Index]