| Title: | Path-Based Access and Manipulation of Nested Lists |
|---|---|
| Description: | Allows users to list data structures using path-based navigation. Provides intuitive methods for storing, accessing, and manipulating nested data through simple path strings. Key features include strict mode validation, path existence checking, recursive operations, and automatic parent-level creation. Designed for use cases requiring organized storage of complex nested data while maintaining simple access patterns. Particularly useful for configuration management, nested settings, and any application where data naturally forms a tree-like structure. |
| Authors: | Mohamed El Fodil Ihaddaden [aut, cre] |
| Maintainer: | Mohamed El Fodil Ihaddaden <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0 |
| Built: | 2026-05-06 07:23:02 UTC |
| Source: | https://github.com/feddelegrand7/slash |
Path-based access and manipulation for R lists
Path-based access and manipulation for R lists
The slash class provides tools for working with hierarchical R lists using path-like strings (e.g., "a/b/c"). Rather than creating a new data structure, it adds convenient path-based access methods to standard R lists, supporting: - Both named and numeric (1-based) indexing - Strict mode for error checking - Various operations for list manipulation
new()
Create a new slash object
slash$new(data = list(), strict = FALSE)
dataInitial data (must be a list)
strictIf TRUE, attempts to access non-existent paths will error
A new 'slash' object
get()
Get value at specified path
slash$get(path = NULL, default = NULL)
pathPath to the element (e.g., "a/b/c" or "1/2/3")
defaultValue to return if path doesn't exist (NULL by default)
The value at the specified path, or default if not found
set()
Set value at specified path
slash$set(path, value)
pathPath to the element
valueValue to set
The slash object (invisibly) for chaining
exists()
Check if path exists
slash$exists(path)
pathPath to check
TRUE if path exists, FALSE otherwise
delete()
Delete element at specified path
slash$delete(path)
pathPath to delete
The slash object (invisibly) for chaining
clear()
Clear all data
slash$clear()
The slash object (invisibly) for chaining
get_all()
Get all data as a list
slash$get_all()
The complete data structure
print()
Print summary of slash object
slash$print(show_full = FALSE)
show_fullIf TRUE, shows full structure (FALSE by default)
print_list()
Print list structure at path
slash$print_list(path = NULL)
pathPath to print (NULL for root)
list_paths()
List all available paths
slash$list_paths()
Character vector of all paths in the data structure
is_strict()
Check if in strict mode
slash$is_strict()
TRUE if in strict mode, FALSE otherwise
set_strict()
Set strict mode
slash$set_strict(strict)
strictLogical value for strict mode
The slash object (invisibly) for chaining
filter_paths()
Filter paths by regex pattern
slash$filter_paths(pattern, ignore_case = FALSE)
patternRegex pattern to match against paths
ignore_caseTRUE to ignore cases, FALSE otherwise. Defaults to FALSE.
Character vector of matching paths
print_tree()
Print a tree-like diagram of the list structure
slash$print_tree(path = NULL)
pathOptional starting path (NULL for root)
clone()
The objects of this class are cloneable with this method.
slash$clone(deep = FALSE)
deepWhether to make a deep clone.