Learn R Programming

chronicler (version 0.2.2)

record: Decorates a function to output objects of type `chronicle`.

Description

Decorates a function to output objects of type `chronicle`.

Usage

record(.f, .g = (function(x) NA), strict = 2, diff = "none")

Value

A function which returns objects of type `chronicle`. `chronicle` objects carry several elements: a `value` which is the result of the function evaluated on its inputs and a second object called `log_df`. `log_df` contains logging information, which can be read using `read_log()`. `log_df` is a data frame with columns: outcome, function, arguments, message, start_time, end_time, run_time, g and diff_obj.

Arguments

.f

A function to decorate.

.g

Optional. A function to apply to the intermediary results for monitoring purposes. Defaults to returning NA.

strict

Controls if the decorated function should catch only errors (1), errors and warnings (2, the default) or errors, warnings and messages (3).

diff

Whether to show the diff between the input and the output ("full"), just a summary of the diff ("summary"), or none ("none", the default)

Details

To chain multiple decorated function, use `bind_record()` or ` If the `diff` parameter is set to "full", `diffobj::diffObj()` (or `diffobj::summary(diffobj::diffObj()`, if diff is set to "summary") gets used to provide the diff between the input and the output. This diff can be found in the `log_df` element of the result, and can be viewed using `check_diff()`.

Examples

Run this code
record(sqrt)(10)

Run the code above in your browser using DataLab