resolve.defaults: Determine Values of Variables Using Several Default Rules

View source: R/resolve.defaults.R

resolve.defaultsR Documentation

Determine Values of Variables Using Several Default Rules

Description

Determine the values of variables by applying several different default rules in a given order.

Usage

   resolve.defaults(..., .MatchNull = TRUE, .StripNull = FALSE)

   resolve.1.default(.A, ...)

Arguments

...

Several lists of name=value pairs.

.MatchNull

Logical value. If TRUE (the default), an entry of the form name=NULL will be treated as assigning the value NULL to the variable name. If FALSE, such entries will be ignored.

.StripNull

Logical value indicating whether entries of the form name=NULL should be removed from the result.

.A

Either a character string giving the name of the variable to be extracted, or a list consisting of one name=value pair giving the variable name and its fallback default value.

Details

These functions determine the values of variables by applying a series of default rules, in the order specified.

Each of the arguments ... should be a list of name=value pairs giving a value for a variable name. Each list could represent a set of arguments given by the user, or a rule assigning default values to some variables. Lists that appear earlier in the sequence of arguments ... take precedence.

The arguments ... will be concatenated into a single list. The earliest occurrence of each name is then used to determine the final value of the variable name.

The function resolve.defaults returns a list of name=value pairs for all variables encountered. It is commonly used to decide the values of arguments to be passed to another function using do.call.

The function resolve.1.default returns the value of the specified variable as determined by resolve.defaults. It is commonly used inside a function to determine the value of an argument.

Value

The result of resolve.defaults is a list of name=value pairs.

The result of resolve.1.default can be any kind of value.

Author(s)

\adrian

See Also

do.call

Examples

  user <- list(day="Friday")
  ruleA <- list(month="Jan", gravity=NULL)
  ruleB <- list(day="Tuesday", month="May", gravity=42)
  resolve.defaults(user, ruleA, ruleB)
  resolve.defaults(user, ruleA, ruleB, .StripNull=TRUE)
  resolve.defaults(user, ruleA, ruleB, .MatchNull=FALSE)

  resolve.1.default("month", user, ruleA, ruleB)

spatstat.utils documentation built on Oct. 24, 2023, 9:08 a.m.