selectElements | R Documentation |
select (and rename, if required) elements from list. Stop with message if elements do not exist
selectElements(x, elements = NULL, do.stop = TRUE, do.warn = TRUE)
x |
list |
elements |
vector of element names. The names of named elements will be the names in the output list |
do.stop |
this flag controls whether the function stops ( |
do.warn |
if |
list containing the elements of x
that are specified in
elements
or x[[elements]]
if length of elements
is 1
or list()
if elements
is empty. If the elements in vector
elements
are named, these names are used in the output list.
L <- list(a = 1, b = 2, c = 3, d = 4)
# Select elements
selectElements(L, c("a", "c"))
# Select and rename at the same time
selectElements(L, elements = c(a.new = "a", c.new = "c", "b"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.