walk_nested_dict: Recursively Walk Through a Nested Dictionary

View source: R/walk_nested_dict.R

walk_nested_dictR Documentation

Recursively Walk Through a Nested Dictionary

Description

This function performs a recursive search through a nested dictionary-like structure in R, looking for a specific term and collecting its values. It's useful for extracting specific pieces of data from complex, deeply nested results.

Usage

walk_nested_dict(my_result, term, outputs = list(), depth = 0, maxdepth = 25)

Arguments

my_result

The nested dictionary-like structure to search through.

term

The term to search for within the nested dictionary.

outputs

An initially empty list to store the results of the search, default is an empty list.

depth

The current depth of the recursion, default is 0.

maxdepth

The maximum depth to recurse, default is 25. If exceeded, the function issues a warning and returns NULL.

Value

A list of values associated with the term found in the nested dictionary. Returns NULL if the term is not found or if maximum recursion depth is exceeded.


rPDBapi documentation built on Oct. 19, 2024, 5:08 p.m.