Learn R Programming

checkmate (version 1.0)

checkFunction: 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.
.var.name
[character(1)] Name for x. Defaults to a heuristic to determine the name using deparse and substitute.
args
[character] Expected formal arguments.
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.

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

Run this code
testFunction(mean)
 testFunction(mean, args = "x")

Run the code above in your browser using DataLab