Learn R Programming

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

326,352

Version

2.3.2

License

BSD_3_clause + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

July 29th, 2024

Functions in checkmate (2.3.2)

checkDirectoryExists

Check for existence and access rights of directories
checkDate

Check that an argument is a Date
checkDataFrame

Check if an argument is a data frame
checkDisjunct

Check if an argument is disjunct from a given set
checkDataTable

Check if an argument is a data table
checkClass

Check the class membership of an argument
checkCount

Check if an argument is a count
checkComplex

Check if an argument is a vector of type complex
checkCharacter

Check if an argument is a vector of type character
checkChoice

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

Check existence and access rights of files
checkFALSE

Check if an argument is FALSE
checkDouble

Check that an argument is a vector of type double
checkFlag

Check if an argument is a flag
checkEnvironment

Check if an argument is an environment
checkInt

Check if an argument is a single integerish value
checkFormula

Check if an argument is a formula
checkFunction

Check if an argument is a function
checkInteger

Check if an argument is vector of type integer
checkFactor

Check if an argument is a factor
checkNumber

Check if an argument is a single numeric value
checkLogical

Check if an argument is a vector of type logical
checkIntegerish

Check if an object is an integerish vector
checkMultiClass

Check the class membership of an argument
checkNull

Check if an argument is NULL
checkNamed

Check if an argument is named
checkNumeric

Check that an argument is a vector of type numeric
checkNames

Check names to comply to specific rules
checkMatrix

Check if an argument is a matrix
checkList

Check if an argument is a list
checkString

Check if an argument is a string
checkPathForOutput

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

Check if an argument is a single atomic value
checkPOSIXct

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

Check if an argument is an R6 class
checkPermutation

Check if the arguments are permutations of each other.
checkSetEqual

Check if an argument is equal to a given set
checkScalarNA

Check if an argument is a single missing value
checkRaw

Check if an argument is a raw vector
checkOS

Check the operating system
matchArg

Partial Argument Matching
makeExpectation

Turn a Check into an Expectation
makeTest

Turn a Check into a Test
makeAssertion

Turn a Check into an Assertion
checkTRUE

Check if an argument is TRUE
checkTibble

Check if an argument is a tibble
%??%

Coalesce operator
checkVector

Check if an argument is a vector
checkmate-package

checkmate: Fast and Versatile Argument Checks
checkSubset

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

Quick argument checks on (builtin) R types
vname

Lookup a variable name
register_test_backend

Select Backend for Unit Tests
qassertr

Quick recursive arguments checks on lists and data frames
wf

Get the index of the first/last TRUE
AssertCollection

Collect multiple assertions
asInteger

Convert an argument to an integer
anyNaN

Check if an object contains NaN values
checkArray

Check if an argument is an array
checkAtomicVector

Check that an argument is an atomic vector
checkAccess

Check file system access rights
anyInfinite

Check if an object contains infinite values
assert

Combine multiple checks into one assertion
allMissing

Check if an object contains missing values
checkAtomic

Check that an argument is an atomic vector