#' @title Check for metacharacters
#' @description Test whether a string contains metacharacters or not.
#' @param x A character string.
#' @return A boolean.
#' @export
has_metachr <- function(x) {
assert_that(is.string(x))
grepl(r"{[\\\[\](){}|?$^*+]}", x, perl = TRUE)
}
#' @title Check for names
#' @description Test whether an object has names or not.
#' @param x Object to test.
#' @param all If `TRUE`, will test whether all elements have a name.
#' @export
has_names <- function(x, all = FALSE) {
.names <- names(x)
if (is.null(.names)) return(FALSE)
if (is_false(all)) return(TRUE)
all(nzchar(.names))
}
are_same_length <- function(x, y) length(x) == length(y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.