| Title: | Enhanced Adverbial Functions |
|---|---|
| Description: | Provides new_partialised() and new_composed(), which extend partial() and compose() functions of 'purrr' to make it easier to extract and replace arguments and functions. It also has additional adverbial functions. |
| Authors: | Mizuki Uchida [aut, cre] |
| Maintainer: | Mizuki Uchida <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.1 |
| Built: | 2026-05-17 08:05:21 UTC |
| Source: | https://github.com/uchidamizuki/adverbial |
as_step(f, name = NULL)as_step(f, name = NULL)
f |
A function to be wrapped. |
name |
The name of the step. If |
as_step() wraps a function to be used as a step in a step-by-step
process.
A function that takes a step-by-step object and additional arguments, and returns the updated step-by-step object.
end_step(object)end_step(object)
object |
The object to end the step-by-step process for. |
end_step() ends the step-by-step process and removes the step-by-step
attributes from the object.
The object with the step-by-step attributes removed.
Create composed functions
new_composed(fns, dir = NULL, ..., class = character())new_composed(fns, dir = NULL, ..., class = character())
fns |
A list of functions to compose. |
dir |
Direction of composition, either |
... |
Additional arguments for attributes. |
class |
Name of subclass. |
A composed function that inherits from adverbial_function_compose.
square <- function(x) x ^ 2 cdist <- new_composed(list(square = square, sum = sum, sqrt = sqrt)) cdist(1:10) cdist$sum <- new_partialised(sum, list(na.rm = TRUE)) cdist(c(1:10, NA))square <- function(x) x ^ 2 cdist <- new_composed(list(square = square, sum = sum, sqrt = sqrt)) cdist(1:10) cdist$sum <- new_partialised(sum, list(na.rm = TRUE)) cdist(c(1:10, NA))
Create partialised functions
new_partialised(f, args, ..., class = character())new_partialised(f, args, ..., class = character())
f |
A function. |
args |
A list of default arguments. |
... |
Additional arguments for attributes. |
class |
Name of subclass. |
A adverbial_function_partial function.
dist <- function(x, y) { sqrt(x ^ 2 + y ^ 2) } pdist <- new_partialised(dist, list(x = 3)) pdist(y = 4)dist <- function(x, y) { sqrt(x ^ 2 + y ^ 2) } pdist <- new_partialised(dist, list(x = 3)) pdist(y = 4)
step_by_step(steps)step_by_step(steps)
steps |
A named vector of steps to be completed. The names of the vector are the names of the steps, and the values are the descriptions of the steps. |
step_by_step() creates a step-by-step object that can be used to track the
progress of a process.
It is useful for long-running processes where you want to keep track of
the steps that have been completed and the steps that are still to be done.
A function that takes an object and returns a step-by-step object.