Learn R Programming

jaatha (version 2.7.0)

checkType: Checks if a variable is of a given type and calls stop() on type mismatch

Description

See heading. Side-effect warning: Calls stop() on type mismatch.

Usage

checkType(variable, type, required = T, allow.na = T)

Arguments

variable
the variable to check
type
the name of the type the variable should have. Can be num/numeric, vec/vector mat/matrix or fun/function. Can also be s/single, in that case it must be a vector of length one . If a vector of type names is given, the variable must be of all types.
required
A boolean that indicates whether the variable must be specified or can be missing. Value of NULL also counts as missing.
allow.na
If FALSE, an error is returned if the variable contains NA values. Only works for vectors.

Value

  • nothing