simplify_lst_lst: Simplify list of lists

Description Usage Arguments Details Value Examples

Description

Simplify a list of lists by eliminating the top-level list.

Usage

1
simplify_lst_lst(lst, unnamed_prefix = "name")

Arguments

lst

a list of lists, each of which should be moved up one level in the list hierarchy.

unnamed_prefix

character: string to use as a prefix for naming unnamed list items in the event that any list items are unnamed.

Details

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.

Value

list: the items in lst but each moved one level up in the list hierarchy, resulting in a list of single elements.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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)

toniprice/jutebag documentation built on May 12, 2019, 4:39 a.m.