#' Assert
#'
#' @param x Object to check
#' @return If the check is successful x will be returned
#' invisibly. If the check is not successful an error will
#' be thrown.
#' @name assert
NULL
#' Assert that an object is a list
#'
#' @inheritParams assert
#' @inherit assert return
#'
#' @export
assert_list <- function(x) {
assert(is_list)(x)
}
#' Assert that an object is a logical vector
#'
#' The assertion will succeed for vectors containing
#' combinations of TRUE, FALSE, and NA. The vector or vector
#' elements can have attributes.
#'
#' The assertion will succeed for vectors containing
#' combinations of TRUE, FALSE, and NA. The vector may have
#' attributes and/or have length zero.
#'
#' @inheritParams assert
#' @inherit assert return
#'
#' @export
assert_logical <- function(x) {
assert(is_logical)(x)
}
#' Assert that an object is an integer vector
#'
#' The assertion will succeed for vectors containing
#' combinations of integers and NA_integer_. The vector may
#' have attributes and/or have length zero.
#'
#' @inheritParams assert
#' @inherit assert return
#'
#' @export
assert_integer <- function(x) {
assert(is_integer)(x)
}
#' Assert that an object is a double vector
#'
#' The assertion will succeed for vectors containing
#' combinations of doubles, NA_real_, NaN, -Inf, Inf. The
#' vector may have attributes and/or have length zero.
#'
#' @inheritParams assert
#' @inherit assert return
#'
#' @export
assert_double <- function(x) {
assert(is_double)(x)
}
#' Assert that an object is a character vector
#'
#' This assertion will succeed for vectors containing
#' combinations of characters and NA_character_. The vector
#' may have attributes and/or have length zero.
#'
#' @inheritParams assert
#' @inherit assert return
#'
#' @export
assert_character <- function(x) {
assert(is_character)(x)
}
#' Assert that an object is a complex vector
#'
#' This assertion will succeed for vectors containing
#' combinations of complex numbers and NA_complex_. The
#' vector may have attributes and/or have length zero.
#'
#' @inheritParams assert
#' @inherit assert return
#'
#' @export
assert_complex <- function(x) {
assert(is_complex)(x)
}
#' Assert that an object is a raw vector
#'
#' This assertion will succeed for vectors containing raw
#' bytes. The vector may have attributes and/or have length
#' zero.
#'
#' @inheritParams assert
#' @inherit assert return
#'
#' @export
assert_raw <- function(x) {
assert(is_raw)(x)
}
#' Assert that an object has no attributes
#'
#' This assertion will succeed for objects without
#' attributes.
#'
#' @inheritParams assert
#' @inherit assert return
#'
#' @export
assert_bare <- function(x) {
assert(is_bare)(x)
}
#' Assert that an object is a vector
#'
#' This assertion will succeed for atomic vectors or lists.
#' The vector may have attributes and/or have length zero.
#'
#' @inheritParams assert
#' @inherit assert return
#'
#' @export
assert_vector <- function(x) {
assert(is_vector)(x)
}
#' @export
assert_pure_integer <- function(x) {
assert(is_pure_integer)(x)
}
#' @export
assert_pure_vector <- function(x) {
assert(is_pure_vector)(x)
}
#' @export
assert_pure_integer_scalar <- function(x) {
assert(is_pure_integer_scalar)(x)
}
#' @export
assert_pure_scalar <- function(x) {
assert(is_pure_scalar)(x)
}
#' @export
assert_pure_numeric <- function(x) {
assert(is_pure_numeric)(x)
}
#' @export
assert_unary_function <- function(x) {
assert(is_unary_function)(x)
}
#' @export
assert_binary_function <- function(x) {
assert(is_binary_function)(x)
}
#' @export
assert_pure_list <- function(x) {
assert(is_pure_list)(x)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.