A practical R utility function called `set_function_params()` that automates the tedious process of setting function parameters in the global environment for interactive debugging. When debugging R functions with many parameters, developers normally have to manually assign each default value. This function uses `formals()` to extract all parameters from a given function and assigns their default values to a specified environment (global by default), returning a data frame showing which parameters were set and their values. The post demonstrates its use on a 23-parameter plotting function from the `clav` package.

4m read timeFrom r-bloggers.com
Post cover image
Table of contents
Related

Sort: