is.output.same: Checks if functions will produce identical output

Description Usage Arguments Details Value See Also Examples

Description

The use for this is to evaluate your code while you're cleaning your functions. You can have a function call as the first argument and the name of another function as the second argument, then it will evaluate the functions with the arguments of the call and see if the output is identical.

Usage

1
is.output.same(.call, ..., quiet = FALSE)

Arguments

.call

Function call, such as ".call = my_function(x = 1:3)"

...

One or more function names

quiet

Optional warning suppression

Details

Use only in pipe chains with a length of one, or it will use the code at the top of the pipe-chain. Also it's not recommended to use pipes with this function, as it undoes the evaluation of prior code in the pipe. If you don't pipe in .call, then the function operates off the fact that a call given as an argument is treated as a promise, allowing the code to be wrapped in substitute() inside the function.

Value

logical - TRUE if outputs are identical

See Also

find_call_piped

Examples

1
2
3
4
is.output.same(purrr::map(1:3, cumsum), lapply) # TRUE
is.output.same(cumsum(1:3), cumprod)     # FALSE
is.output.same(sum(1:3), prod)           # FALSE for outputs of different class
is.output.same(mean(1:3), prod)          # FALSE

visuelledata/frite documentation built on May 17, 2019, 1:30 p.m.