Missing: Does an Argument have a Value?

MissingR Documentation

Does an Argument have a Value?

Description

Missing can be used to test whether a value is the missing argument.

Usage

Missing(x, name)

Arguments

x

an object of class "ParsedArgs".

name

character string or symbol, the name of the argument to test for missing-ness.

Details

Missing will return FALSE when an argument has a value, even if it was not provided. See Examples.

Missing does not evaluate its argument name, similar to missing.

Value

TRUE or FALSE

Examples

parser <- essentials::ArgumentParser()
parser$add.argument("--arg1")
parser$add.argument("--arg2", default = "def")
pargs <- parser$parse.args()


list(
    arg1 = essentials::Missing(pargs, arg1),
    arg2 = essentials::Missing(pargs, "arg2")
)


# with R >= 4.1.0, use the forward pipe operator `|>` to
# make calls to `Missing` more intuitive:
# list(
#     arg1 = pargs |> essentials::Missing(arg1),
#     arg2 = pargs |> essentials::Missing("arg2")
# )

ArcadeAntics/essentials documentation built on Nov. 7, 2024, 4:33 p.m.