getPathsAndValuesFromRecursiveList: Get Paths and String Values from Recursive List

View source: R/list.R

getPathsAndValuesFromRecursiveListR Documentation

Get Paths and String Values from Recursive List

Description

Get Paths and String Values from Recursive List

Usage

getPathsAndValuesFromRecursiveList(x, path = "")

Arguments

x

a list

path

start path

Value

data frame with columns path and value. The data frame contains all non-list elements that are contained in x, coerced to character, in column value, together with the sequence of element names "leading" to the value when starting at x. For example, the path to element x$a$a1 is /a/a1 (see example).

Examples

# Define a recursive list
x <- list(
  a = list(a1 = "A1", a2 = "A2"),
  b = list(b1 = "B1", b2 = "B2", b3 = "B3"),
  c = list(c1 = list(c11 = "C11"), c2 = list(c21 = "C21", c22 = "C22"))
)

# Get all non-list-elements and their "path" as a data frame
getPathsAndValuesFromRecursiveList(x)


KWB-R/kwb.utils documentation built on April 1, 2024, 7:12 a.m.