| Title: | Read-Only Variable Bundles |
|---|---|
| Description: | Easily create list-like structures with constant, read-only variables. Combines the flexibility of lists with read-only fields. Supports defensive programming by throwing errors on field assignment, helping mitigate the introduction of logical runtime bugs. Compatibility updates by Renova. |
| Authors: | Brandon C. Loudermilk [aut, cre] |
| Maintainer: | Brandon C. Loudermilk <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.0.9001 |
| Built: | 2026-11-15 20:38:38 UTC |
| Source: | https://github.com/renova-r/VarBundle |
Returns field names of VarBundle Object
field_names(x)field_names(x)
x |
(VarBundle) |
(character vector)
Prints a VarBundle object.
## S3 method for class 'VarBundle' print(x, ...)## S3 method for class 'VarBundle' print(x, ...)
x |
(VarBundle) |
... |
(additional args) |
VarBundle objects store read-only variables in a list-like
structure. Variable values can be accessed via the '$' operator
(vb$foobar) or via field name(vb[["foobar"]]).
After a VarBundle object has been created, new fields cannot be added
and existing field values cannot be modified.
Field names can be accessed via field_names.
Simple VarBundle objects that only contain atomic, scalar values are
useful for storing configuration information. The object method
$as.data.frame() will return a data.frame version of the VarBundle.
This can be persisted to disk and subsequently modified by the end user
to change system parameters.
varbundle(x)varbundle(x)
x |
(list or data.frame) |
(VarBundle)
# Access via $ sales <- varbundle(list(min = 1, max = 10)) sales$min # Access via name my_var <- field_names(sales)[1] sales[[my_var]] # Create data.frame df <- sales$as.data.frame() # Create VarBundle from data.frame corp_sales <- varbundle(df) class(corp_sales)# Access via $ sales <- varbundle(list(min = 1, max = 10)) sales$min # Access via name my_var <- field_names(sales)[1] sales[[my_var]] # Create data.frame df <- sales$as.data.frame() # Create VarBundle from data.frame corp_sales <- varbundle(df) class(corp_sales)