Title: | Check the Properties of Common R Objects |
---|---|
Description: | Expressive, assertive, pipe-friendly functions to check the properties of common R objects. In the case of failure the functions issue informative error messages. Superseded by the 'chk' package. |
Authors: | Joe Thorley [aut, cre] , Evan Amies-Galonski [ctb] (-3188), Poisson Consulting [cph, fnd] |
Maintainer: | Joe Thorley <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.5.0.9001 |
Built: | 2024-11-01 16:19:09 UTC |
Source: | https://github.com/poissonconsulting/checkr |
Checks an objects attributes.
check_attributes( x, values = NULL, exclusive = FALSE, order = FALSE, names = TRUE, class = TRUE, x_name = substitute(x), error = TRUE )
check_attributes( x, values = NULL, exclusive = FALSE, order = FALSE, names = TRUE, class = TRUE, x_name = substitute(x), error = TRUE )
x |
The object to check. |
values |
NULL (default) or a character vector specifying the column names or a named list specifying the column names and values. |
exclusive |
A flag indicating whether other elements are not permitted. |
order |
A flag indicating whether the elements have to occur in the same order as values. |
names |
A flag specifying whether names should be considered an attribute. |
class |
A flag specifying whether class should be considered an attribute. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
x <- 1 attributes(x) <- list(y = 2L) check_attributes(x, values = list(y = 3:4), error = FALSE)
x <- 1 attributes(x) <- list(y = 2L) check_attributes(x, values = list(y = 3:4), error = FALSE)
Checks if x is a character vector with no attributes including names.
check_character(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
check_character(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
coerce |
A flag indicating whether to coerce a factor to a character vector and drop attributes including names. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_character("1", error = FALSE) check_character(1:2, error = FALSE)
check_character("1", error = FALSE) check_character(1:2, error = FALSE)
Checks if object is a string (non-missing character scalar with no attributes including names).
check_chr(x, coerce = FALSE, x_name = substitute(x), error = TRUE) check_string(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
check_chr(x, coerce = FALSE, x_name = substitute(x), error = TRUE) check_string(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
coerce |
A flag indicating whether to coerce a factor scalar to a string and drop attributes including names. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_chr(1, error = FALSE) check_chr("1", error = FALSE) check_chr(c("1", "2"), error = FALSE)
check_chr(1, error = FALSE) check_chr("1", error = FALSE) check_chr(c("1", "2"), error = FALSE)
Checks that an object inherits from one or more classes.
check_classes( x, classes = character(0), exclusive = FALSE, order = FALSE, x_name = substitute(x), error = TRUE )
check_classes( x, classes = character(0), exclusive = FALSE, order = FALSE, x_name = substitute(x), error = TRUE )
x |
The object to check. |
classes |
A character vector of the classes x should inherit from. |
exclusive |
A flag indicating whether other classes are not permitted. |
order |
A flag indicating whether the object classes have to occur in the same order as classes. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
The classes of an object can be returned using the class()
function.
An invisible copy of x (if it doesn't throw an error).
check_classes(list()) check_classes(list(), "list") check_classes(list(), "numeric", error = FALSE)
check_classes(list()) check_classes(list(), "list") check_classes(list(), "numeric", error = FALSE)
Checks the column names of a data frame as returned by the colnames()
function.
The function can check the order of the columns and whether other columns are permitted.
check_colnames( x, colnames = character(0), exclusive = FALSE, order = FALSE, x_name = substitute(x), error = TRUE )
check_colnames( x, colnames = character(0), exclusive = FALSE, order = FALSE, x_name = substitute(x), error = TRUE )
x |
The data to check. |
colnames |
A character vector of the column names. |
exclusive |
A flag indicating whether other columns are not permitted. |
order |
A flag indicating whether the columns have to occur in the same order as colnames. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_missing_colnames()
and check_data()
data <- data.frame(x = 1, y = 2, z = 0) check_colnames(data, c("y", "x"), error = FALSE) check_colnames(data, c("y", "x"), exclusive = TRUE, error = FALSE) check_colnames(data, c("y", "x"), order = TRUE, error = FALSE) check_colnames(data, c("a"), error = FALSE)
data <- data.frame(x = 1, y = 2, z = 0) check_colnames(data, c("y", "x"), error = FALSE) check_colnames(data, c("y", "x"), exclusive = TRUE, error = FALSE) check_colnames(data, c("y", "x"), order = TRUE, error = FALSE) check_colnames(data, c("a"), error = FALSE)
Checks if an object is a count (non-negative integer or if coerce = TRUE
non-negative numeric whole number).
check_count(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
check_count(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
coerce |
A flag indicating whether to coerce a non-negative numeric (dbl) whole number to a count and drop attributes (including names). |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_count(-1L, error = FALSE) check_count(1L, error = FALSE) check_count(1, error = FALSE) check_count(1, coerce = TRUE, error = FALSE) check_count(1.01, coerce = TRUE, error = FALSE)
check_count(-1L, error = FALSE) check_count(1L, error = FALSE) check_count(1, error = FALSE) check_count(1, coerce = TRUE, error = FALSE) check_count(1.01, coerce = TRUE, error = FALSE)
Checks whether an object is a data frame. Can also check the number of rows, the names and order and values of the columns as well as whether particular columns form a unique key.
check_data( x, values = NULL, nrow = NA, exclusive = FALSE, order = FALSE, key = character(0), x_name = substitute(x), error = TRUE )
check_data( x, values = NULL, nrow = NA, exclusive = FALSE, order = FALSE, key = character(0), x_name = substitute(x), error = TRUE )
x |
The object to check. |
values |
NULL (default) or a character vector specifying the column names or a named list specifying the column names and values. |
nrow |
A flag indicating whether x should have rows (versus no rows) or a missing value indicating no requirements or a count or count range of the number of rows. @return An invisible copy of x (if it doesn't throw an error). |
exclusive |
A flag indicating whether other columns are not permitted. |
order |
A flag indicating whether the columns have to occur in the same order as values. |
key |
A character vector of the columns that represent a unique key. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_colnames()
, check_nrow()
and check_key()
z <- data.frame( Count = c(0L, 3L, 3L, 0L, NA), Longitude = c(0, 0, 90, 90, 180), Latitude = c(0, 90, 90.2, 100, -180), Type = factor(c("Good", "Bad", "Bad", "Bad", "Bad"), levels = c("Good", "Bad")), Extra = TRUE, Comments = c("In Greenwich", "Somewhere else", "I'm lost", "I didn't see any", "Help"), stringsAsFactors = FALSE) check_data(z, values = list( Count = 1, Extra = NA, Latitude = c(45, 90) ), exclusive = TRUE, order = TRUE, nrow = 10L, key = "Longitude", error = FALSE)
z <- data.frame( Count = c(0L, 3L, 3L, 0L, NA), Longitude = c(0, 0, 90, 90, 180), Latitude = c(0, 90, 90.2, 100, -180), Type = factor(c("Good", "Bad", "Bad", "Bad", "Bad"), levels = c("Good", "Bad")), Extra = TRUE, Comments = c("In Greenwich", "Somewhere else", "I'm lost", "I didn't see any", "Help"), stringsAsFactors = FALSE) check_data(z, values = list( Count = 1, Extra = NA, Latitude = c(45, 90) ), exclusive = TRUE, order = TRUE, nrow = 10L, key = "Longitude", error = FALSE)
Checks if x is a date (non-missing unnamed Date scalar).
check_date(x, coerce = FALSE, x_name = substitute(x), error = TRUE) check_day(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
check_date(x, coerce = FALSE, x_name = substitute(x), error = TRUE) check_day(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
coerce |
A flag indicating whether to coerce a date time (POSIXt scalar) to a Date and remove names. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_date(Sys.Date(), error = FALSE) check_date(Sys.time(), error = FALSE) check_date(Sys.time(), coerce = TRUE, error = FALSE)
check_date(Sys.Date(), error = FALSE) check_date(Sys.time(), error = FALSE) check_date(Sys.time(), coerce = TRUE, error = FALSE)
Checks if x is a dbl (non-missing numeric scalar with no attributes including names).
check_dbl(x, coerce = FALSE, x_name = substitute(x), error = TRUE) check_number(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
check_dbl(x, coerce = FALSE, x_name = substitute(x), error = TRUE) check_number(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
coerce |
A flag indicating whether to coerce a scalar integer to a dbl and drop attributes including names. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_dbl(1, error = FALSE) check_dbl(1L, error = FALSE) check_dbl(c(1,2), error = FALSE)
check_dbl(1, error = FALSE) check_dbl(1L, error = FALSE) check_dbl(c(1,2), error = FALSE)
Checks if x is a datetime (non-missing unnamed POSIXct scalar).
check_dttm( x, coerce = FALSE, tzone = "UTC", x_name = substitute(x), error = TRUE ) check_datetime( x, coerce = FALSE, tzone = "", x_name = substitute(x), error = TRUE )
check_dttm( x, coerce = FALSE, tzone = "UTC", x_name = substitute(x), error = TRUE ) check_datetime( x, coerce = FALSE, tzone = "", x_name = substitute(x), error = TRUE )
x |
The object to check. |
coerce |
A flag indicating whether to coerce a date to a dttm (using the time zone tzone) and remove names. |
tzone |
A string of the time zone where "" is the current time zone. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_dttm(Sys.Date(), error = FALSE) check_dttm(Sys.time(), error = FALSE)
check_dttm(Sys.Date(), error = FALSE) check_dttm(Sys.time(), error = FALSE)
Checks if x is an environment.
check_environment(x, x_name = substitute(x), error = TRUE)
check_environment(x, x_name = substitute(x), error = TRUE)
x |
The object to check. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_environment(1, error = FALSE) check_environment(.GlobalEnv, error = FALSE)
check_environment(1, error = FALSE) check_environment(.GlobalEnv, error = FALSE)
Checks if x is a flag or NA (missing logical scalar).
check_flag_na(x, coerce = TRUE, x_name = substitute(x), error = TRUE)
check_flag_na(x, coerce = TRUE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
coerce |
A flag indicating whether to drop attributes including names. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
Useful when using flag to pass one of three options.
An invisible copy of x (if it doesn't throw an error).
Checks if x is a function.
check_function(x, nargs = NA, x_name = substitute(x), error = TRUE)
check_function(x, nargs = NA, x_name = substitute(x), error = TRUE)
x |
The object to check. |
nargs |
A count of the number of arguments or count range of the minimum and maximum number of arguments. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_function(character, error = FALSE) check_function(character, nargs = 0L, error = FALSE)
check_function(character, error = FALSE) check_function(character, nargs = 0L, error = FALSE)
Checks whether all the elements of an object match a regular expression.
check_grepl( x, pattern = ".*", regex = pattern, x_name = substitute(x), error = TRUE ) check_regex(x, regex = ".*", x_name = substitute(x), error = TRUE)
check_grepl( x, pattern = ".*", regex = pattern, x_name = substitute(x), error = TRUE ) check_regex(x, regex = ".*", x_name = substitute(x), error = TRUE)
x |
The object to check. |
pattern |
A string of the regular expression. |
regex |
A string of the regular expression (deprecated for pattern). |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_nchar()
and check_pattern()
check_grepl("foo", "fo") check_grepl("foo", "fo$", error = FALSE)
check_grepl("foo", "fo") check_grepl("foo", "fo$", error = FALSE)
Checks whether the elements of x are all of the same class. It works on vectors, matrices and arrays which, by definition will always be homogenous and lists and data frames which may or may not be homogenous.
check_homogenous( x, strict = FALSE, recursive = FALSE, x_name = substitute(x), error = TRUE )
check_homogenous( x, strict = FALSE, recursive = FALSE, x_name = substitute(x), error = TRUE )
x |
The object to check. |
strict |
A flag indicating whether all the objects must have identical classes or just share one or more classes. |
recursive |
A flag indicating whether the check should be applied recursively. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_vector()
, check_list()
and check_data()
check_homogenous(1:2) check_homogenous(list(1,2)) check_homogenous(list(1,TRUE), error = FALSE)
check_homogenous(1:2) check_homogenous(list(1,2)) check_homogenous(list(1,TRUE), error = FALSE)
Checks if an object inherits from a class.
check_inherits(x, class, x_name = substitute(x), error = TRUE)
check_inherits(x, class, x_name = substitute(x), error = TRUE)
x |
The object to check. |
class |
A string of the class x should inherit from. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_inherits(list(), "list") check_inherits(list(), "numeric", error = FALSE)
check_inherits(list(), "list") check_inherits(list(), "numeric", error = FALSE)
Checks if x is a int (non-missing integer scalar with no attributes including names).
check_int(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
check_int(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
coerce |
A flag indicating whether to coerce a numeric (dbl) whole number to an int and drop attributes including names. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_int(1, error = FALSE) check_int(1L, error = FALSE) check_int(1:2, error = FALSE)
check_int(1, error = FALSE) check_int(1L, error = FALSE) check_int(1:2, error = FALSE)
Checks if x is an integer vector with no attributes including names.
check_integer(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
check_integer(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
coerce |
A flag indicating whether to coerce a numeric (dbl) whole number vector to an integer vector and drop attributes including names. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_integer(1, error = FALSE) check_integer(1L, error = FALSE) check_integer(1:2, error = FALSE)
check_integer(1, error = FALSE) check_integer(1L, error = FALSE) check_integer(1:2, error = FALSE)
Checks that all the elements in atomic vector x intersect with those in atomic vector y.
check_intersection( x, y, all_y = FALSE, x_name = substitute(x), y_name = substitute(y), error = TRUE )
check_intersection( x, y, all_y = FALSE, x_name = substitute(x), y_name = substitute(y), error = TRUE )
x |
The object to check. |
y |
The second atomic vector. |
all_y |
A flag indicating whether all the elements in y should have a match in x. |
x_name |
A string of the name of the object x. |
y_name |
A string of the name of the object y. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
x1 <- 1:3 x2 <- 1:4 check_intersection(x1, x2) check_intersection(x2, x1, error = FALSE)
x1 <- 1:3 x2 <- 1:4 check_intersection(x1, x2) check_intersection(x2, x1, error = FALSE)
Checks that the columns in data frame x form a many-to-one join with the corresponding columns in y, ie, the join is a unique key in y and all the rows in x have a match in y.
check_join( x, y, by = NULL, all_y = FALSE, x_name = substitute(x), y_name = substitute(y), error = TRUE )
check_join( x, y, by = NULL, all_y = FALSE, x_name = substitute(x), y_name = substitute(y), error = TRUE )
x |
The object to check. |
y |
The parent data frame. |
by |
A character vector or named character vector of the columns to join by. |
all_y |
A flag indicating whether all the rows in y should have a match in x. |
x_name |
A string of the name of the object x. |
y_name |
A string of the name of the object y. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
data1 <- data.frame(x = 1:2) data2 <- data.frame(x = 3:5, y = 2L) check_join(data1, data2, error = FALSE) check_join(data1, data2, by = c(x = "y"), error = FALSE)
data1 <- data.frame(x = 1:2) data2 <- data.frame(x = 3:5, y = 2L) check_join(data1, data2, error = FALSE) check_join(data1, data2, by = c(x = "y"), error = FALSE)
Checks that columns in a data frame represent a unique key. By default all the columns are checked.
check_key( x, key = names(x), na_distinct = FALSE, x_name = substitute(x), error = TRUE )
check_key( x, key = names(x), na_distinct = FALSE, x_name = substitute(x), error = TRUE )
x |
The data to check. |
key |
A character vector of the column names representing the key. |
na_distinct |
A flag specifying whether missing values should be considered distinct. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
data <- data.frame(x = 1:1, y = 1:2) check_key(data, "x", error = FALSE) check_key(data, c("y", "x"), error = FALSE)
data <- data.frame(x = 1:1, y = 1:2) check_key(data, "x", error = FALSE) check_key(data, c("y", "x"), error = FALSE)
Checks whether the number of elements in an object is an exact number, within a range or 0 vs positive.
check_length(x, length = TRUE, x_name = substitute(x), error = TRUE)
check_length(x, length = TRUE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
length |
A flag indicating whether x should have elements (versus no elements) or a missing value indicating no requirements or a count or count range of the number of elements or a count vector of the permitted number of elements. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_vector()
, check_list()
and check_data()
check_length(2) check_length(character(0), length = 0) check_length(NULL, error = FALSE) check_length(list(), error = FALSE)
check_length(2) check_length(character(0), length = 0) check_length(NULL, error = FALSE) check_length(list(), error = FALSE)
Checks whether x is an object of length 1.
check_length1(x, x_name = substitute(x), error = TRUE)
check_length1(x, x_name = substitute(x), error = TRUE)
x |
The object to check. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_length1(2) check_length1(1:2, error = FALSE) check_length1(NULL, error = FALSE) check_length1(list(), error = FALSE)
check_length1(2) check_length1(1:2, error = FALSE) check_length1(NULL, error = FALSE) check_length1(list(), error = FALSE)
Checks the levels in a factor including the order and whether other levels are permitted.
check_levels( x, levels, exclusive = TRUE, order = TRUE, x_name = substitute(x), error = TRUE )
check_levels( x, levels, exclusive = TRUE, order = TRUE, x_name = substitute(x), error = TRUE )
x |
The object to check. |
levels |
A character vector of the levels. |
exclusive |
A flag indicating whether other levels are not permitted. |
order |
A flag indicating whether the object levels have to occur in the same order as names. To check whether x is an ordered factor use
|
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_nlevels()
and check_vector()
check_levels(1, c("x", "y"), error = FALSE) check_levels(factor(1), c("x", "y"), error = FALSE)
check_levels(1, c("x", "y"), error = FALSE) check_levels(factor(1), c("x", "y"), error = FALSE)
Checks if x is a flag (non-missing logical scalar with no attributes including names).
check_lgl(x, coerce = FALSE, x_name = substitute(x), error = TRUE) check_flag(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
check_lgl(x, coerce = FALSE, x_name = substitute(x), error = TRUE) check_flag(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
coerce |
A flag indicating whether to drop attributes including names. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_lgl(1, error = FALSE) check_lgl(FALSE, error = FALSE) check_lgl(c(FALSE, TRUE), error = FALSE)
check_lgl(1, error = FALSE) check_lgl(FALSE, error = FALSE) check_lgl(c(FALSE, TRUE), error = FALSE)
Checks whether an object is a list and optionally the names and values of its elements.
check_list( x, values = NULL, length = NA, unique = FALSE, named = NA, exclusive = FALSE, order = FALSE, x_name = substitute(x), error = TRUE )
check_list( x, values = NULL, length = NA, unique = FALSE, named = NA, exclusive = FALSE, order = FALSE, x_name = substitute(x), error = TRUE )
x |
The object to check. |
values |
NULL (default) or a character vector specifying the column names or a named list specifying the column names and values. |
length |
A flag indicating whether x should have elements (versus no elements) or a missing value indicating no requirements or a count or count range of the number of elements or a count vector of the permitted number of elements. |
unique |
A flag indicating whether the values must be unique. |
named |
A flag indicating whether the list must be named or unnamed or a regular expression that must match all the names or count or count range of the number of characters in the names or NA if it doesn't matter if the list is named. |
exclusive |
A flag indicating whether other elements are not permitted. |
order |
A flag indicating whether the elements have to occur in the same order as values. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_length()
and check_unique()
check_list(list()) check_list(list(x1 = 2, x2 = 1:2), values = list(x1 = 1, x2 = 1L))
check_list(list()) check_list(list(x1 = 2, x2 = 1:2), values = list(x1 = 1, x2 = 1L))
Checks if x is a logical vector with no attributes including names.
check_logical(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
check_logical(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
coerce |
A flag indicating whether to drop attributes including names. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_logical(1, error = FALSE) check_logical(FALSE, error = FALSE) check_logical(c(FALSE, TRUE), error = FALSE)
check_logical(1, error = FALSE) check_logical(FALSE, error = FALSE) check_logical(c(FALSE, TRUE), error = FALSE)
Checks whether specific colnames are missing from a data frame.
check_missing_colnames(x, colnames, x_name = substitute(x), error = TRUE)
check_missing_colnames(x, colnames, x_name = substitute(x), error = TRUE)
x |
The data to check. |
colnames |
A character vector of the column names that must be missing from x. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_colnames()
and check_data()
data <- data.frame(x = 1, y = 2, z = 0) check_missing_colnames(data, c("y", "x", "a"), error = FALSE) check_missing_colnames(data, "a", error = FALSE)
data <- data.frame(x = 1, y = 2, z = 0) check_missing_colnames(data, c("y", "x", "a"), error = FALSE) check_missing_colnames(data, "a", error = FALSE)
Checks whether specific names are missing from an object.
check_missing_names(x, names, x_name = substitute(x), error = TRUE)
check_missing_names(x, names, x_name = substitute(x), error = TRUE)
x |
The named object to check. |
names |
A character vector of the names that must be missing from x. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
vec <- c(x = 1, y = 2, z = 0) check_missing_names(vec, c("y", "x", "a"), error = FALSE) check_missing_names(vec, "a", error = FALSE)
vec <- c(x = 1, y = 2, z = 0) check_missing_names(vec, c("y", "x", "a"), error = FALSE) check_missing_names(vec, "a", error = FALSE)
Checks whether each element of a character vector is a syntactically valid name.
check_name(x, x_name = substitute(x), coerce = FALSE, error = TRUE)
check_name(x, x_name = substitute(x), coerce = FALSE, error = TRUE)
x |
The object to check. |
x_name |
A string of the name of the object x. |
coerce |
A flag specifying whether to coerce a factor to a character vector and drop attributes including names. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
vec <- c("x", "x.y", "x y") check_name(vec, error = FALSE)
vec <- c("x", "x.y", "x y") check_name(vec, error = FALSE)
Checks whether an object is named.
check_named( x, nchar = c(0L, chk_max_int()), pattern = ".*", regex = pattern, unique = FALSE, x_name = substitute(x), error = TRUE )
check_named( x, nchar = c(0L, chk_max_int()), pattern = ".*", regex = pattern, unique = FALSE, x_name = substitute(x), error = TRUE )
x |
The object to check. |
nchar |
A count or count range of the number of characters. |
pattern |
A string of the regular expression that must match all names. |
regex |
A string of the regular expression that must match all names. |
unique |
A flag indicating whether the names must be unique. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_unnamed()
, check_names()
and check_missing_names()
check_named(2, error = FALSE) x <- 1 names(x) <- "y" check_named(x, error = FALSE)
check_named(2, error = FALSE) x <- 1 names(x) <- "y" check_named(x, error = FALSE)
Checks the names of an object as returned by the names()
function.
The function can check the order of the names and whether other names are permitted.
check_names( x, names = character(0), exclusive = FALSE, order = FALSE, unique = FALSE, complete = TRUE, x_name = substitute(x), error = TRUE )
check_names( x, names = character(0), exclusive = FALSE, order = FALSE, unique = FALSE, complete = TRUE, x_name = substitute(x), error = TRUE )
x |
The object to check. |
names |
A character vector of the names. |
exclusive |
A flag indicating whether other names are not permitted. |
order |
A flag indicating whether the object names have to occur in the same order as names. |
unique |
A flag indicating whether all the object names have to be unique. |
complete |
A flag indicating whether all the possible names have to be represented. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
vec <- c(x = 1, y = 2, z = 0) check_names(vec, c("y", "x"), error = FALSE) check_names(vec, c("y", "x"), exclusive = TRUE, error = FALSE) check_names(vec, c("y", "x"), order = TRUE, error = FALSE) check_names(vec, c("a"), error = FALSE)
vec <- c(x = 1, y = 2, z = 0) check_names(vec, c("y", "x"), error = FALSE) check_names(vec, c("y", "x"), exclusive = TRUE, error = FALSE) check_names(vec, c("y", "x"), order = TRUE, error = FALSE) check_names(vec, c("a"), error = FALSE)
Checks the number of characters in the elements of an object.
check_nchar(x, nchar = TRUE, x_name = substitute(x), error = TRUE)
check_nchar(x, nchar = TRUE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
nchar |
A flag indicating whether x should have characters or a missing value indicating no requirements or a count or count range of the number of characters. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_pattern()
and check_regex()
check_nchar(c("foo", "bar"), nchar = 3)
check_nchar(c("foo", "bar"), nchar = 3)
Checks the number of columns of a data frame.
check_ncol(x, ncol = TRUE, x_name = substitute(x), error = TRUE)
check_ncol(x, ncol = TRUE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
ncol |
A flag indicating whether x should have columns (versus no columns) or a missing value indicating no requirements or a count or count range of the number of columns. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_ncol(data.frame(x = 1), error = FALSE) check_ncol(data.frame(x = 1:2), ncol = 1, error = FALSE)
check_ncol(data.frame(x = 1), error = FALSE) check_ncol(data.frame(x = 1:2), ncol = 1, error = FALSE)
Checks if x is a negative dbl (non-missing numeric scalar with no attributes including names).
check_neg_dbl(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
check_neg_dbl(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
coerce |
A flag indicating whether to coerce a scalar integer to a dbl and drop attributes including names. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_neg_dbl(1, error = FALSE) check_neg_dbl(0L, error = FALSE) check_neg_dbl(0, error = FALSE)
check_neg_dbl(1, error = FALSE) check_neg_dbl(0L, error = FALSE) check_neg_dbl(0, error = FALSE)
Checks if x is a negative int (non-missing integer scalar with no attributes including names).
check_neg_int(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
check_neg_int(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
coerce |
A flag indicating whether to coerce a numeric (dbl) whole number to an int and drop attributes including names. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_neg_int(0L, error = FALSE) check_neg_int(-1L, error = FALSE)
check_neg_int(0L, error = FALSE) check_neg_int(-1L, error = FALSE)
Checks the number of levels of an object.
check_nlevels(x, nlevels = TRUE, x_name = substitute(x), error = TRUE)
check_nlevels(x, nlevels = TRUE, x_name = substitute(x), error = TRUE)
x |
The data to check. |
nlevels |
A flag indicating whether x should have elements (versus no elements) or a missing value indicating no requirements or a count or count range of the number of elements. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_levels()
and check_vector()
check_nlevels(factor(1), error = FALSE) check_nlevels(factor(1), nlevels = 2, error = FALSE)
check_nlevels(factor(1), error = FALSE) check_nlevels(factor(1), nlevels = 2, error = FALSE)
Checks an object has no attributes.
check_no_attributes( x, names = TRUE, class = TRUE, x_name = substitute(x), error = TRUE )
check_no_attributes( x, names = TRUE, class = TRUE, x_name = substitute(x), error = TRUE )
x |
The object to check. |
names |
A flag specifying whether names should be considered an attribute. |
class |
A flag specifying whether class should be considered an attribute. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
x <- 1 attributes(x) <- list(y = 2L) check_no_attributes(x, error = FALSE)
x <- 1 attributes(x) <- list(y = 2L) check_no_attributes(x, error = FALSE)
Checks if x is a non-negative dbl (non-missing numeric scalar with no attributes including names).
check_noneg_dbl(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
check_noneg_dbl(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
coerce |
A flag indicating whether to coerce a scalar integer to a dbl and drop attributes including names. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_noneg_dbl(1, error = FALSE) check_noneg_dbl(0L, error = FALSE) check_noneg_dbl(0, error = FALSE)
check_noneg_dbl(1, error = FALSE) check_noneg_dbl(0L, error = FALSE) check_noneg_dbl(0, error = FALSE)
Checks if x is a count (non-missing non-negative integer scalar with no attributes including names).
check_noneg_int(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
check_noneg_int(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
coerce |
A flag indicating whether to coerce a non-negative numeric (dbl) whole number to a count and drop attributes (including names). |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_noneg_int(1, error = FALSE) check_noneg_int(0L, error = FALSE) check_noneg_int(1L, error = FALSE)
check_noneg_int(1, error = FALSE) check_noneg_int(0L, error = FALSE) check_noneg_int(1L, error = FALSE)
Checks the number of rows of a data frame.
check_nrow(x, nrow = TRUE, x_name = substitute(x), error = TRUE)
check_nrow(x, nrow = TRUE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
nrow |
A flag indicating whether x should have rows (versus no rows) or a missing value indicating no requirements or a count or count range of the number of rows. @return An invisible copy of x (if it doesn't throw an error). |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
check_nrow(data.frame(x = 1), error = FALSE) check_nrow(data.frame(x = integer(0)), error = FALSE) check_nrow(data.frame(x = 1:2), nrow = 1, error = FALSE)
check_nrow(data.frame(x = 1), error = FALSE) check_nrow(data.frame(x = integer(0)), error = FALSE) check_nrow(data.frame(x = 1:2), nrow = 1, error = FALSE)
Checks whether an object is NULL.
check_null(x, x_name = substitute(x), error = TRUE)
check_null(x, x_name = substitute(x), error = TRUE)
x |
The object to check. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_null(1, error = FALSE) check_null(NULL, error = FALSE)
check_null(1, error = FALSE) check_null(NULL, error = FALSE)
Checks if x is an numeric (double) vector with no attributes including names.
check_numeric(x, coerce = FALSE, x_name = substitute(x), error = TRUE) check_double(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
check_numeric(x, coerce = FALSE, x_name = substitute(x), error = TRUE) check_double(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
coerce |
A flag indicating whether to coerce a integer vector to an double vector and drop attributes including names. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_numeric(1, error = FALSE) check_numeric(1L, error = FALSE) check_numeric(1:2, error = FALSE)
check_numeric(1, error = FALSE) check_numeric(1L, error = FALSE) check_numeric(1:2, error = FALSE)
Checks whether all or some of the elements of x match pattern using grepl()
.
check_pattern(x, pattern, all = TRUE, x_name = substitute(x), error = TRUE)
check_pattern(x, pattern, all = TRUE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
pattern |
A string of the regular expression. |
all |
A flag indicating whether all or some of the element must match pattern. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_nchar()
and check_regex()
Checks if x is a positive dbl (non-missing numeric scalar with no attributes including names).
check_pos_dbl(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
check_pos_dbl(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
coerce |
A flag indicating whether to coerce a scalar integer to a dbl and drop attributes including names. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_pos_dbl(1, error = FALSE) check_pos_dbl(0L, error = FALSE) check_pos_dbl(0, error = FALSE)
check_pos_dbl(1, error = FALSE) check_pos_dbl(0L, error = FALSE) check_pos_dbl(0, error = FALSE)
Checks if x is a positive int (non-missing integer scalar with no attributes including names).
check_pos_int(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
check_pos_int(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
coerce |
A flag indicating whether to coerce a numeric (dbl) whole number to an int and drop attributes including names. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_pos_int(0, error = FALSE) check_pos_int(1L, error = FALSE) check_pos_int(1:2, error = FALSE)
check_pos_int(0, error = FALSE) check_pos_int(1L, error = FALSE) check_pos_int(1:2, error = FALSE)
Checks if x is a probability (non-missing dbl between 0 and 1 inclusive with no attributes including names).
check_prob(x, coerce = FALSE, x_name = substitute(x), error = TRUE) check_probability(x, coerce = FALSE, x_name = substitute(x), error = TRUE) check_prop(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
check_prob(x, coerce = FALSE, x_name = substitute(x), error = TRUE) check_probability(x, coerce = FALSE, x_name = substitute(x), error = TRUE) check_prop(x, coerce = FALSE, x_name = substitute(x), error = TRUE)
x |
The object to check. |
coerce |
A flag indicating whether to coerce an integer to a dbl and drop attributes including names. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_prob(1, error = FALSE) check_prob(1.1, error = FALSE) check_prob(c(0, 1), error = FALSE)
check_prob(1, error = FALSE) check_prob(1.1, error = FALSE) check_prob(c(0, 1), error = FALSE)
Checks if x is proportions vector - non-missing dbls between 0 and 1 that sum to 1.
check_props(x, x_name = substitute(x), error = TRUE)
check_props(x, x_name = substitute(x), error = TRUE)
x |
The object to check. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
Checks whether a data frame has the same columns of the same classes as a
second data frame which means they can be rbind()
ed without a
problem.
check_rbind( x, y, exclusive = TRUE, order = FALSE, x_name = substitute(x), y_name = substitute(y), error = TRUE )
check_rbind( x, y, exclusive = TRUE, order = FALSE, x_name = substitute(x), y_name = substitute(y), error = TRUE )
x |
The first data frame. |
y |
The second data frame. |
exclusive |
A flag indicating whether other columns are not permitted. |
order |
A flag indicating whether the columns have to occur in the same order. |
x_name |
A string of the name of the object x. |
y_name |
A string of the name of the object y. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_rbind(datasets::mtcars, datasets::mtcars)
check_rbind(datasets::mtcars, datasets::mtcars)
Checks whether an object is an atomic vector with one element.
check_scalar( x, values = NULL, named = FALSE, attributes = named, only = FALSE, x_name = substitute(x), error = TRUE )
check_scalar( x, values = NULL, named = FALSE, attributes = named, only = FALSE, x_name = substitute(x), error = TRUE )
x |
The object to check. |
values |
NULL or a vector specifying the values. |
named |
A flag indicating whether the scalar must be named or unnamed or NA if it doesn't matter if the scalar is named. |
attributes |
A flag indicating whether the scalar must or must not have attributes or NA if it doesn't matter if the scalar is named. |
only |
A flag indicating whether only the actual values are permitted. It only affects values with two or less non-missing elements. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_scalar(1) check_scalar(c(1,2), error = FALSE) check_scalar(1, c(2,3), error = FALSE)
check_scalar(1) check_scalar(c(1,2), error = FALSE) check_scalar(1, c(2,3), error = FALSE)
Checks whether object x is sorted using !is.unsorted(x, na.rm = TRUE)
.
check_sorted(x, x_name = substitute(x), error = TRUE)
check_sorted(x, x_name = substitute(x), error = TRUE)
x |
The object to check. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_vector()
and check_list()
check_sorted(1:2, error = FALSE) check_sorted(2:1, error = FALSE)
check_sorted(1:2, error = FALSE) check_sorted(2:1, error = FALSE)
Checks an objects tzone attribute.
check_tzone(x, tzone = "UTC", x_name = substitute(x), error = TRUE)
check_tzone(x, tzone = "UTC", x_name = substitute(x), error = TRUE)
x |
The object to check. |
tzone |
A string of the time zone. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_tzone(Sys.Date(), error = FALSE) x <- as.POSIXct("2000-01-02 03:04:55", tz = "Etc/GMT+8") check_tzone(x, tzone = "PST8PDT", error = FALSE)
check_tzone(Sys.Date(), error = FALSE) x <- as.POSIXct("2000-01-02 03:04:55", tz = "Etc/GMT+8") check_tzone(x, tzone = "PST8PDT", error = FALSE)
Checks whether all elements of an object are unique.
check_unique(x, x_name = substitute(x), error = TRUE)
check_unique(x, x_name = substitute(x), error = TRUE)
x |
The object to check. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_unique(2, error = FALSE) check_unique(c(2,2), error = FALSE) check_unique(1:2, error = FALSE) check_unique(character(0), error = FALSE) check_unique(NULL, error = FALSE) check_unique(list(), error = FALSE)
check_unique(2, error = FALSE) check_unique(c(2,2), error = FALSE) check_unique(1:2, error = FALSE) check_unique(character(0), error = FALSE) check_unique(NULL, error = FALSE) check_unique(list(), error = FALSE)
Checks whether an objects is unnamed.
check_unnamed(x, x_name = substitute(x), error = TRUE)
check_unnamed(x, x_name = substitute(x), error = TRUE)
x |
The object to check. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_named()
, check_names()
and check_missing_names()
check_unnamed(2, error = FALSE) x <- 1 names(x) <- "y" check_unnamed(x, error = FALSE)
check_unnamed(2, error = FALSE) x <- 1 names(x) <- "y" check_unnamed(x, error = FALSE)
Checks whether ... is unused. It can only be used in functions.
check_unused(..., x_name = "...", error = TRUE)
check_unused(..., x_name = "...", error = TRUE)
... |
The arguments to check. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
fun <- function(...) check_unused(..., error = FALSE) fun() fun(1)
fun <- function(...) check_unused(..., error = FALSE) fun() fun(1)
Check Atomic Vector
check_vector( x, values = NULL, length = NA, unique = FALSE, sorted = FALSE, named = NA, attributes = named, names = TRUE, class = TRUE, only = FALSE, x_name = substitute(x), error = TRUE )
check_vector( x, values = NULL, length = NA, unique = FALSE, sorted = FALSE, named = NA, attributes = named, names = TRUE, class = TRUE, only = FALSE, x_name = substitute(x), error = TRUE )
x |
The object to check. |
values |
NULL or a vector specifying the values. |
length |
A flag indicating whether x should have elements (versus no elements) or a missing value indicating no requirements or a count or count range of the number of elements or a count vector of the permitted number of elements. |
unique |
A flag indicating whether the values must be unique. |
sorted |
A flag indicating whether the vector must be sorted. |
named |
A flag indicating whether the vector must be named or unnamed or NA if it doesn't matter. |
attributes |
A flag indicating whether the vector must or must not have attributes or NA if it doesn't matter. |
names |
A flag specifying whether names should be considered an attribute. |
class |
A flag specifying whether class should be considered an attribute. |
only |
A flag indicating whether only the actual values are permitted. It only affects values with two or less non-missing elements. |
x_name |
A string of the name of the object x. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible copy of x (if it doesn't throw an error).
check_vector(2:1, length = 3, sorted = TRUE, named = TRUE, error = FALSE) check_vector(c("one", "two", "four"), values = c("one", "two", "two"), error = FALSE)
check_vector(2:1, length = 3, sorted = TRUE, named = TRUE, error = FALSE) check_vector(c("one", "two", "four"), values = c("one", "two", "two"), error = FALSE)
Checks that at least one check passes.
checkor(..., error = TRUE)
checkor(..., error = TRUE)
... |
The checks to check. |
error |
A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails. |
An invisible flag indicating whether at least one check passes (if it doesn't throw an error).
checkor(check_null(NULL), check_null(1), error = FALSE) checkor(check_null(1), check_null(1), error = FALSE) checkor(check_null(1), check_null(2), error = FALSE)
checkor(check_null(NULL), check_null(1), error = FALSE) checkor(check_null(1), check_null(1), error = FALSE) checkor(check_null(1), check_null(2), error = FALSE)
Fail
chk_fail(..., error)
chk_fail(..., error)
... |
The message. |
error |
A flag indicating whether to return an error (the default) or a warning. |
Max Double
chk_max_dbl()
chk_max_dbl()
An dbl of the maximum numeric value for the system.
chk_max_dbl()
chk_max_dbl()
Max Int
chk_max_int()
chk_max_int()
An int of the maximum integer value for the system.
chk_max_int()
chk_max_int()
Min Double
chk_min_dbl()
chk_min_dbl()
An dbl of the minimum numeric value for the system.
chk_min_dbl()
chk_min_dbl()
Min Integer
chk_min_int()
chk_min_int()
An int of the minimum integer value for the system.
chk_min_int()
chk_min_int()
Tiny Positive Double
chk_tiny_dbl()
chk_tiny_dbl()
An dbl of the tiniest positive numeric value for the system.
chk_tiny_dbl()
chk_tiny_dbl()