isIntegerOrNaOrNanScalarOrNull: Wrapper for the checkarg function, using specific parameter...

Description Usage Arguments Details Value Examples

View source: R/isIntegerOrNaOrNanScalarOrNull.R

Description

This function can be used in 3 ways:

  1. Return TRUE or FALSE depending on whether the argument checks are passed. This is suitable e.g. for if statements that take further action if the argument does not pass the checks.

  2. Throw an exception if the argument does not pass the checks. This is suitable e.g. when no further action needs to be taken other than throwing an exception if the argument does not pass the checks.

  3. Same as (2) but by supplying a default value, a default can be assigned in a single statement, when the argument is NULL. The checks are still performed on the returned value, and an exception is thrown when not passed.

Usage

1
2
isIntegerOrNaOrNanScalarOrNull(argument, default = NULL, stopIfNot = FALSE,
  message = NULL, argumentName = NULL)

Arguments

argument

See checkarg function.

default

See checkarg function.

stopIfNot

See checkarg function.

message

See checkarg function.

argumentName

See checkarg function.

Details

Actual call to checkarg: checkarg(argument, "N", default = default, stopIfNot = stopIfNot, nullAllowed = TRUE, n = 1, zeroAllowed = TRUE, negativeAllowed = TRUE, positiveAllowed = TRUE, nonIntegerAllowed = FALSE, naAllowed = TRUE, nanAllowed = TRUE, infAllowed = FALSE, message = message, argumentName = argumentName)

Value

See checkarg function.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
isIntegerOrNaOrNanScalarOrNull(2)
   # returns TRUE (argument is valid)
isIntegerOrNaOrNanScalarOrNull("X")
   # returns FALSE (argument is invalid)
#isIntegerOrNaOrNanScalarOrNull("X", stopIfNot = TRUE)
   # throws exception with message defined by message and argumentName parameters
isIntegerOrNaOrNanScalarOrNull(2, default = 1)
   # returns 2 (the argument, rather than the default, since it is not NULL)
#isIntegerOrNaOrNanScalarOrNull("X", default = 1)
   # throws exception with message defined by message and argumentName parameters
isIntegerOrNaOrNanScalarOrNull(NULL, default = 1)
   # returns 1 (the default, rather than the argument, since it is NULL)

checkarg documentation built on May 2, 2019, 3:26 p.m.