Learn R Programming

cleanr (version 1.4.0)

set_cleanr_options: Set Options for cleanr

Description

A convenience function for options.

Usage

set_cleanr_options(..., reset = FALSE, overwrite = TRUE)

Value

Invisibly

TRUE.

Arguments

...

See options. See function_checks and file_checks for options to be set with cleanr. Use get_cleanr_options to get the current values. cleanr's standard defaults are: cat(paste(names(cleanr::gco()), cleanr::gco(flatten_list = FALSE), sep = "=", collapse = "\n"), "\n")

reset

[boolean(1)]
Reset all cleanr options to the package's defaults?

overwrite

[boolean(1)]
Overwrite options already set? Is set to FALSE on package loading to ensure your previously set cleanr options won't get overridden. Just ignore that argument.

Details

cleanr loads a couple of options as defaults for its functions. The defaults are stored in a list element of options. All checks (see function_checks and file_checks) can be disabled by setting the corresponding option list item to NULL or FALSE.

See Also

Other option wrappers: get_cleanr_options()

Examples

Run this code
# R.C. Martin's Clean Code recommends monadic argument lists.
cleanr::set_cleanr_options(max_num_arguments = 1)
# R.C. Martin's Clean Code recommends functions less than 20 lines long.
cleanr::set_cleanr_options(max_lines = 30, max_lines_of_code = 20)
# same as above:
cleanr::set_cleanr_options(list(max_lines = 30, max_lines_of_code = 20))
cleanr::get_cleanr_options(flatten_list = TRUE)
# we delete all options and set some anew
options("cleanr" = NULL)
options("cleanr" = list(max_lines = 30, max_lines_of_code = 20))
# fill the missing options with the package's defaults:
cleanr::set_cleanr_options(overwrite = FALSE)
cleanr::get_cleanr_options(flatten_list = TRUE)
# reset to the package's defaults:
cleanr::set_cleanr_options(reset = TRUE)
cleanr::get_cleanr_options(flatten_list = TRUE)

Run the code above in your browser using DataLab