Movatterモバイル変換


[0]ホーム

URL:


potions

easy options management






Overview

Often it is useful to set bespoke options for a single workflow, orwithin a single package, without altering global options that influenceother users or packages. This is possible usingbase::options() and related functions, however doing sorequires care, and occasionally some bespoke knowledge.potions makes options management as easy as possible, bydecreasing programmers’ cognitive burden while storing and retrievinginformation. It does this by following three guiding principles:

In combination, these features should make it easy for users anddevelopers to manage options usingpotions.

To install from CRAN:

install.packages("potions")

To install from GitHub:

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

To store data inoptions(), usebrew()

library(potions)brew(list(x =1,y =list(a =2,b =4)))# use a listbrew(x =1)# or as named arguments

Then you can usepour() to get the information youneed:

pour()|>str()# get all data#> List of 2#>  $ x: num 1#>  $ y:List of 2#>   ..$ a: num 2#>   ..$ b: num 4pour("x")# get a subset of data#> [1] 1pour("y","a")# for nested data#> [1] 2

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

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

[8]ページ先頭

©2009-2025 Movatter.jp