reverse.list.hierarchy | R Documentation |
This function reverses the hierarchy of a given, 2 level, nested list. The function will ensure that all lists at the same level have the same names, and then transpose the structure, creating a new list for each unique name. Any missing elements in the original lists are not included in the final output. The result is a list where the top-level names are derived from the unique names found at the lower levels of the input list.
reverse.list.hierarchy(list_of_lists)
list_of_lists |
A list where some or all elements are themselves lists. The hierarchy of this list will be reversed. |
A list with the elements of the original list in reversed order.
https://stackoverflow.com/a/15263737
list_of_lists <- list("z1" = list(a = 1, b = 2), "z2" = list(b = 4, a = 1, c = 0))
reverse.list.hierarchy(list_of_lists)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.