| Type: | Package |
| Title: | Path-Based Access and Manipulation of Nested Lists |
| Version: | 0.2.0 |
| 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. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| URL: | https://github.com/feddelegrand7/slash, https://feddelegrand7.github.io/slash/ |
| BugReports: | https://github.com/feddelegrand7/slash/issues |
| Suggests: | testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| RoxygenNote: | 7.3.1 |
| Imports: | R6 |
| NeedsCompilation: | no |
| Packaged: | 2025-09-08 04:24:48 UTC; mohamedelfodilihaddaden |
| Author: | Mohamed El Fodil Ihaddaden [aut, cre] |
| Maintainer: | Mohamed El Fodil Ihaddaden <ihaddaden.fodeil@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2025-09-08 07:40:02 UTC |
Path-based access and manipulation for R lists
Description
Path-based access and manipulation for R lists
Path-based access and manipulation for R lists
Details
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
Methods
Public methods
Method new()
Create a new slash object
Usage
slash$new(data = list(), strict = FALSE)
Arguments
dataInitial data (must be a list)
strictIf TRUE, attempts to access non-existent paths will error
Returns
A new 'slash' object
Method get()
Get value at specified path
Usage
slash$get(path = NULL, default = NULL)
Arguments
pathPath to the element (e.g., "a/b/c" or "1/2/3")
defaultValue to return if path doesn't exist (NULL by default)
Returns
The value at the specified path, or default if not found
Method set()
Set value at specified path
Usage
slash$set(path, value)
Arguments
pathPath to the element
valueValue to set
Returns
The slash object (invisibly) for chaining
Method exists()
Check if path exists
Usage
slash$exists(path)
Arguments
pathPath to check
Returns
TRUE if path exists, FALSE otherwise
Method delete()
Delete element at specified path
Usage
slash$delete(path)
Arguments
pathPath to delete
Returns
The slash object (invisibly) for chaining
Method clear()
Clear all data
Usage
slash$clear()
Returns
The slash object (invisibly) for chaining
Method get_all()
Get all data as a list
Usage
slash$get_all()
Returns
The complete data structure
Method print()
Print summary of slash object
Usage
slash$print(show_full = FALSE)
Arguments
show_fullIf TRUE, shows full structure (FALSE by default)
Method print_list()
Print list structure at path
Usage
slash$print_list(path = NULL)
Arguments
pathPath to print (NULL for root)
Method list_paths()
List all available paths
Usage
slash$list_paths()
Returns
Character vector of all paths in the data structure
Method is_strict()
Check if in strict mode
Usage
slash$is_strict()
Returns
TRUE if in strict mode, FALSE otherwise
Method set_strict()
Set strict mode
Usage
slash$set_strict(strict)
Arguments
strictLogical value for strict mode
Returns
The slash object (invisibly) for chaining
Method filter_paths()
Filter paths by regex pattern
Usage
slash$filter_paths(pattern, ignore_case = FALSE)
Arguments
patternRegex pattern to match against paths
ignore_caseTRUE to ignore cases, FALSE otherwise. Defaults to FALSE.
Returns
Character vector of matching paths
Method print_tree()
Print a tree-like diagram of the list structure
Usage
slash$print_tree(path = NULL)
Arguments
pathOptional starting path (NULL for root)
Method clone()
The objects of this class are cloneable with this method.
Usage
slash$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.