simplify_lst_lst: Simplify list of lists

View source: R/simplify_lst_lst.R

simplify_lst_lstR Documentation

Simplify list of lists

Description

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

Usage

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

The 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

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

Examples

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/jute documentation built on Jan. 11, 2023, 8:23 a.m.