checkFunction {checkmate}R Documentation

Check if an argument is a function

Description

Check if an argument is a function

Usage

checkFunction(x, args = NULL, ordered = FALSE)

assertFunction(x, args = NULL, ordered = FALSE, .var.name)

testFunction(x, args = NULL, ordered = FALSE)

Arguments

x

[any]
Object to check.

args

[character]
Expected formal arguments. Checks that a function has no arguments if set to character(0). Default is NULL (no check).

ordered

[logical(1)]
Flag whether the arguments provided in args must be the first length(args) arguments of the function in the specified order. Default is FALSE.

.var.name

[character(1)]
Name for x. Defaults to a heuristic to determine the name using deparse and substitute.

Value

Depending on the function prefix: If the check is successful, all functions return TRUE. If the check is not successful, assertFunction throws an error message, testFunction returns FALSE and checkFunction returns a string with the error message.

See Also

Other basetypes: assertArray, checkArray, testArray; assertAtomicVector, checkAtomicVector, testAtomicVector; assertAtomic, checkAtomic, testAtomic; assertCharacter, checkCharacter, testCharacter; assertComplex, checkComplex, testComplex; assertDataFrame, checkDataFrame, testDataFrame; assertEnvironment, checkEnvironment, testEnvironment; assertFactor, checkFactor, testFactor; assertIntegerish, checkIntegerish, testIntegerish; assertInteger, checkInteger, testInteger; assertList, checkList, testList; assertLogical, checkLogical, testLogical; assertMatrix, checkMatrix, testMatrix; assertNumeric, checkNumeric, testNumeric; assertVector, checkVector, testVector

Examples

testFunction(mean)
testFunction(mean, args = "x")

[Package checkmate version 1.6.0 Index]