Description Usage Arguments Examples
Given a list of lists, this function goes through each element and copies the named element from each sub-list into a top-level element of a new list.
1 | ListExtract(list, name, name.elements = TRUE)
|
list |
List to be reformatted |
name |
Quoted name of sub-list item to extract |
name.elements |
Whether to name the new list elements based on the sub-list
item's name and their order in the original list; defaults to |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # Create and view a nested list
a <- list(letter = 'a', number = 1)
b <- list(letter = 'b', number = 2)
c <- list(letter = 'c', number = 3)
(nested <- list(first = a, second = b, third = c))
# Extract the letter element
ListExtract(nested, 'letter')
# Extract the number element
ListExtract(nested, 'number')
# Extract the number element into an unnamed list
ListExtract(nested, 'number', FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.