Skip to contents

This is the main function that most users will call on. It retrieves data from a potions object stored using brew(). The UI for this function is based on the here package, in that it uses list names separated by commas to navigate through nested content. It differs from here in not requiring those names to be quoted.

Usage

pour(..., .slot, .pkg)

pour_package(..., .pkg)

pour_interactive(..., .slot)

pour_all()

Arguments

...

string: what slots should be returned

.slot

string: Optional manual override to default slot

.pkg

string: Optional manual override to default package

Value

If no arguments are passed to ..., returns a list from the default slot. If ... is supplied (correctly), then returns a vector of values matching those names.

Details

Providing multiple arguments to ... brings back nested values, i.e. pour("x", "y") is for the case of an object structured as list(x = list(y = 1)), rather than list(x = 1, y = 2). For the latter case it would be necessary to call with either no arguments (unlist(pour())), or for greater control, call pour multiple times specifying different entries each time (e.g. z <- c(pour("x"), pour("y"))).

Additional functions are provided in case greater specificity is required. pour_interactive(.slot = ...) is synonymous with pour(.slot = ...), while pour_package(.pkg = ...) is synonymous with pour(.pkg = ...). pour_all() is a shortcut for getOption("potions-pkg"); i.e. to show all data stored using potions by any package or slot, and does not accept any arguments.

Examples

# first import some data
brew(x = 1, y = list(a = 2, b = 3))

# get all data
pour()
#> $x
#> [1] 1
#> 
#> $y
#> $y$a
#> [1] 2
#> 
#> $y$b
#> [1] 3
#> 
#> 

# get only data from slot x
pour("x")
#> [1] 1

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

# optional clean-up
drain()