Learn R Programming

⚠️There's a newer version (2.3.4) of this package.Take me there.

checkmate

Fast and versatile argument checks for R.

Ever used an R function that produced a not-very-helpful error message, just to discover after minutes of debugging that you simply passed a wrong argument?

Blaming the laziness of the package author for not doing such standard checks (in a dynamically typed language such as R) is at least partially unfair, as R makes theses types of checks cumbersome and annoying. Well, that's how it was in the past.

Enter checkmate.

Virtually every standard type of user error when passing arguments into function can be caught with a simple, readable line which produces an informative error message in case. A substantial part of the package was written in C to minimize any worries about execution time overhead. Furthermore, the package provides over 30 expectations to extend the popular testthat package for unit tests.

Installation

For the stable release, just install the latest version from CRAN:

install.packages("checkmate")

For the development version, use devtools:

devtools::install_github("mllg/checkmate")

Resources

Copy Link

Version

Install

install.packages('checkmate')

Monthly Downloads

1,340,729

Version

2.3.1

License

BSD_3_clause + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Michel Lang

Last Published

December 4th, 2023

Functions in checkmate (2.3.1)

checkDataTable

Check if an argument is a data table
checkDate

Check that an argument is a Date
checkCount

Check if an argument is a count
checkClass

Check the class membership of an argument
checkDisjunct

Check if an argument is disjunct from a given set
checkDataFrame

Check if an argument is a data frame
checkChoice

Check if an object is an element of a given set
checkDirectoryExists

Check for existence and access rights of directories
checkCharacter

Check if an argument is a vector of type character
checkComplex

Check if an argument is a vector of type complex
checkInt

Check if an argument is a single integerish value
checkFileExists

Check existence and access rights of files
checkInteger

Check if an argument is vector of type integer
checkEnvironment

Check if an argument is an environment
checkFALSE

Check if an argument is FALSE
checkFlag

Check if an argument is a flag
checkDouble

Check that an argument is a vector of type double
checkFormula

Check if an argument is a formula
checkFunction

Check if an argument is a function
checkFactor

Check if an argument is a factor
checkMultiClass

Check the class membership of an argument
checkIntegerish

Check if an object is an integerish vector
checkList

Check if an argument is a list
checkNames

Check names to comply to specific rules
checkNull

Check if an argument is NULL
checkNumber

Check if an argument is a single numeric value
checkLogical

Check if an argument is a vector of type logical
checkNumeric

Check that an argument is a vector of type numeric
checkMatrix

Check if an argument is a matrix
checkNamed

Check if an argument is named
checkPathForOutput

Check if a path is suited for creating an output file
checkR6

Check if an argument is an R6 class
checkSetEqual

Check if an argument is equal to a given set
checkString

Check if an argument is a string
checkRaw

Check if an argument is a raw vector
checkOS

Check the operating system
checkPOSIXct

Check that an argument is a date/time object in POSIXct format
checkPermutation

Check if the arguments are permutations of each other.
checkmate-package

checkmate: Fast and Versatile Argument Checks
%??%

Coalesce operator
checkScalarNA

Check if an argument is a single missing value
checkScalar

Check if an argument is a single atomic value
makeTest

Turn a Check into a Test
matchArg

Partial Argument Matching
wf

Get the index of the first/last TRUE
checkVector

Check if an argument is a vector
checkTibble

Check if an argument is a tibble
register_test_backend

Select Backend for Unit Tests
vname

Lookup a variable name
qassertr

Quick recursive arguments checks on lists and data frames
checkTRUE

Check if an argument is TRUE
qassert

Quick argument checks on (builtin) R types
checkSubset

Check if an argument is a subset of a given set
makeAssertion

Turn a Check into an Assertion
makeExpectation

Turn a Check into an Expectation
asInteger

Convert an argument to an integer
AssertCollection

Collect multiple assertions
anyInfinite

Check if an object contains infinite values
checkAtomic

Check that an argument is an atomic vector
anyNaN

Check if an object contains NaN values
checkAccess

Check file system access rights
checkAtomicVector

Check that an argument is an atomic vector
checkArray

Check if an argument is an array
assert

Combine multiple checks into one assertion
allMissing

Check if an object contains missing values