Flatten a named list
flatten_named_list.RdThis function takes a named list as input and returns a data frame with two columns: the name of each list element (including parent element names), and its corresponding value. If the input is not a list, the function returns a data frame with a single row containing the value and its parent name (if provided).
Arguments
- lst
A named list to be flattened into a data frame.
- parent_name
A character string indicating the name of the parent list element. This argument is optional and should only be provided if the input list is a child element of a larger parent list. By default, the parent name is set to an empty string.