Learn R Programming

Often it is useful to set bespoke options for a single workflow, or within a single package, without altering global options that influence other users or packages. This is possible using base::options() and related functions, however doing so requires care, and occasionally some bespoke knowledge. potions makes options management as easy as possible, by decreasing programmers’ cognitive burden while storing and retrieving information. It does this by following three guiding principles:

  • minimalist: potions has only three core functions: brew(), pour() and drain()
  • laconic: functions use as few characters as possible
  • familiar: uses a UI for data retrieval based on the here package

In combination, these features should make it easy for users and developers to manage options using potions.

To install from CRAN:

install.packages("potions")

To install from GitHub:

install.packages("remotes")
remotes::install_github("atlasoflivingaustralia/potions")

To store data in options(), use brew()

library(potions)
brew(list(x = 1, y = list(a = 2, b = 4))) # use a list

brew(x = 1) # or as named arguments

Then you can use pour() to get the information you need:

pour() |> str() # get all data
#> List of 2
#>  $ x: num 1
#>  $ y:List of 2
#>   ..$ a: num 2
#>   ..$ b: num 4

pour("x") # get a subset of data
#> [1] 1

pour("y", "a") # for nested data
#> [1] 2

When you are done, simply use drain() to clean up:

drain()

pour() # nothing to return
#> list()

Copy Link

Version

Install

install.packages('potions')

Monthly Downloads

362

Version

0.2.0

License

MPL-2.0

Maintainer

Martin Westgate

Last Published

August 23rd, 2023

Functions in potions (0.2.0)

pour

Retrieve information stored using potions::brew()
read_config

Handle configuration data from a file
potions-class

Methods for potions data
potions

potions: simple options management
drain

Clear package options
brew

Set up potions for easy data retrieval