View source: R/simplify_lst_lst.R
simplify_lst_lst | R Documentation |
Simplify a list of lists by eliminating the top-level list.
simplify_lst_lst(lst, unnamed_prefix = "name")
lst |
A list of lists, each of which should be moved up one level in the list hierarchy. |
unnamed_prefix |
The string to use as a prefix for naming unnamed list items in the event that any list items are unnamed. |
List names are handled as follows: if any list items are named, these names
will be set in the returned list; if any list items are unnamed, their names
will be set to the default value prefixed by unnamed_prefix
with an
integer suffix starting at 1 and incremented for each unnamed item.
The list of items in lst
with each moved one level up in the
list hierarchy, resulting in a list of single elements.
a_1 <- "pineapple" a_2 <- list(uno = 1, due = 2, tre = 3) a_3 <- c(1, 4, 9, 16, 25) lst <- list(list(z_1 = a_1), list(z_2 = a_2), list(z_3 = a_3)) simplify_lst_lst(lst) a_1 <- "pineapple" a_2 <- list(uno = 1, due = 2, tre = 3) a_3 <- c(1, 4, 9, 16, 25) lst <- list(list(a_1), list(z = a_2), list(a_3)) simplify_lst_lst(lst)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.