assert_scalar <- function(x, name = deparse(substitute(x))) {
if (length(x) != 1) {
stop(sprintf("'%s' must be a scalar", name), call. = FALSE)
}
}
assert_character <- function(x, name = deparse(substitute(x))) {
if (!is.character(x)) {
stop(sprintf("'%s' must be character", name), call. = FALSE)
}
}
assert_numeric <- function(x, name = deparse(substitute(x))) {
if (!is.numeric(x)) {
stop(sprintf("'%s' must be numeric", name), call. = FALSE)
}
}
assert_scalar_character <- function(x, name = deparse(substitute(x))) {
assert_scalar(x, name)
assert_character(x, name)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.