#' @importFrom assertthat on_failure<-
is_string <- function(x) {
is.character(x) && length(x) == 1 && !is.na(x)
}
on_failure(is_string) <- function(call, env) {
paste0(sQuote(deparse(call$x)), " is not a string (length 1 character)")
}
is_string_or_null <- function(x) {
is.null(x) || is_string(x)
}
on_failure(is_string_or_null) <- function(call, env) {
paste0(
sQuote(deparse(call$x)),
" must be NULL or a string (length 1 character)"
)
}
is_flag <- function(x) {
is.logical(x) && length(x) == 1 && !is.na(x)
}
on_failure(is_flag) <- function(call, env) {
paste0(sQuote(deparse(call$x)), " is not a flag (length 1 logical)")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.