Package 'VarBundle'

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

Help Index


Names of VarBundle

Description

Returns field names of VarBundle Object

Usage

field_names(x)

Arguments

x

(VarBundle)

Value

(character vector)


Print VarBundle

Description

Prints a VarBundle object.

Usage

## S3 method for class 'VarBundle'
print(x, ...)

Arguments

x

(VarBundle)

...

(additional args)


Create bundle of variables.

Description

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.

Usage

varbundle(x)

Arguments

x

(list or data.frame)

Value

(VarBundle)

Examples

# 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)