Learn R Programming

catchr (version 0.2.31)

catchr_opts: Pass in catchr-specific options

Description

catchr offers a number of options for planning condition handling, and the catchr_opts function provides a way of passing those options to whatever function is handling the planning. If any argument is left unspecified it defaults to the global defaults (accessible via catchr_default_opts(), base::options(), or base::getOption()).

Usage

catchr_opts(
  default_plan = NULL,
  warn_about_terms = NULL,
  bare_if_possible = NULL,
  drop_empty_conds = NULL
)

Arguments

default_plan

The default plan for unnamed input arguments. See get_default_plan() for more details.

warn_about_terms

A logical; if FALSE, will not warn about masking special terms

bare_if_possible

A logical; if TRUE, and no conditions are collected, will return the result of the evaluated expression as-is, without encompassing named list.

drop_empty_conds

A logical; if TRUE, the sublists for conditions that used collect but didn't collect anything will be dropped from the list. Otherwise, they will appear as empty sublists.

Catchr options

catchr's options are specified below. The names of the global default option are preceded by "catchr." so they don't collide with other packages' options (i.e., drop_empty_conds can be accessed via getOption("catchr.drop_empty_conds"):

  • default_plan: The default plan that will be used for unnamed arguments (i.e., conditions specified without plans) to make_plans() or the like. See get_default_plan() for more details. The original package default is c("collect", "muffle").

  • warn_about_terms: If one of its reserved terms would mask a previously defined variable name when catchr is compiling plans, you can specify whether or not a warning will be generated. The original package default is TRUE, which will warn the user of these occurrences.

  • bare_if_possible: When no plans are set to collect conditions, you have the option of returning the value of the evaluated expression by itself, without being the $value element of a list. If bare_if_possible is TRUE and no plans collect conditions, it will return the value without the wrapping list. If one is using catchr extensively, it might be wise to set this option to FALSE so catchr's returned values are always consistent. The original package default is TRUE.

  • drop_empty_conds: If conditions have plans that would collect them but none are raised in the evaluation of an expression, you have the option of dropping their sublists. For example, conditions that aren't warnings, messages, or errors are very rare. If you wanted to return the "misc" condition sublist only when such conditions were raised, you could do this by setting the value to TRUE. The original package default is FALSE.

See Also

The default catchr options, set_default_plan(), get_default_plan()