validFCTs: Check Arguments of a function.

validFCTsR Documentation

Check Arguments of a function.

Description

Check the validity of the arguments in functions.

Usage

validCharacter(
  value1,
  name1 = as.character(substitute(value1)),
  valid.length,
  valid.values = "character",
  refuse.NULL = TRUE,
  refuse.duplicates = FALSE,
  method = NULL,
  addPP = TRUE
)

validClass(
  value1,
  name1 = as.character(substitute(value1)),
  valid.class,
  type = "inherits",
  method = NULL,
  addPP = TRUE
)

validDimension(
  value1,
  value2 = NULL,
  name1 = as.character(substitute(value1)),
  name2 = as.character(substitute(value2)),
  valid.dimension = NULL,
  type = c("NROW", "NCOL"),
  method = NULL,
  addPP = TRUE
)

validInteger(
  value1,
  name1 = as.character(substitute(value1)),
  valid.length,
  min = NULL,
  max = NULL,
  refuse.NA = TRUE,
  refuse.NULL = TRUE,
  refuse.duplicates = FALSE,
  method = NULL,
  addPP = TRUE
)

validLogical(
  value1,
  name1 = as.character(substitute(value1)),
  valid.length,
  refuse.NULL = TRUE,
  refuse.NA = TRUE,
  method = NULL,
  addPP = TRUE
)

validNames(
  value1,
  name1 = as.character(substitute(value1)),
  refuse.NULL = TRUE,
  valid.length = NULL,
  valid.values = NULL,
  required.values = NULL,
  refuse.values = NULL,
  method = NULL,
  addPP = TRUE
)

validNumeric(
  value1,
  name1 = as.character(substitute(value1)),
  valid.length,
  valid.values = NULL,
  min = NULL,
  max = NULL,
  refuse.NA = TRUE,
  refuse.NULL = TRUE,
  refuse.duplicates = FALSE,
  method = NULL,
  addPP = TRUE,
  unlist = FALSE
)

validPath(
  value1,
  name1 = as.character(substitute(value1)),
  type,
  method = NULL,
  addPP = TRUE,
  extension = NULL,
  check.fsep = FALSE
)

Arguments

value1

the value of the (first) argument to be checked

name1

the name of the (first) argument.

valid.length

the acceptable length(s) for the argument. If NULL no test is performed.

valid.values

the acceptable value(s) for the argument. If NULL no test is performed. Can also be "character" or "character_or_logical".

refuse.NULL

should an error be output if value is NULL.

refuse.duplicates

should an error be output if value contains duplicated values.

method

the name of the function using the argument.

addPP

add ": " after the name of the function in the error message.

type

For validDimension: the type of operator used to check the dimensions. For validPath either "dir" or "file" to check whether to path points to an existing directory or file.

value2

the second value of a second argument whose dimensions should be consistent with the first one

name2

the name of the second argument.

min

the minimum acceptable value

max

the maximum acceptable value

refuse.NA

should an error be output if value contains NA.

required.values

values that must appear in the argument

refuse.values

values that must not appear in the argument

unlist

[logical] flatten argument before check.

extension

filter the files by the type of extension.

check.fsep

display a warning when the separator is not correctly specified in

validClass

the acceptable classes(s) for the argument.

validDimension

the acceptable dimension for the argument. If NULL then name2 is used as a reference.

super.classes

uses the is function instead of class to test the class of the object.

Value

An invisible TRUE or an error message.


BuyseTest documentation built on March 31, 2023, 6:55 p.m.