# Functions in this file perform argument checking in the make_env function from env.R
#' @title Value used internally to identify \code{keys} argument
#' @seealso get_keys, all_explicit, any_explicit
.KEY_NAME <- "keys"
#' @title Value used internally to identify \code{values} argument
#' @seealso get_values, all_explicit, any_explicit
.VAL_NAME <- "values"
#' @title Get keys from a named list
#' @param args A \code{list}.
#' @return The \code{keys} component of the supplied \code{list}.
get_keys <- function(args) {
args[[.KEY_NAME]]
}
#' @title Get values from a named list
#' @param args A \code{list}.
#' @return The \code{values} component of the supplied \code{list}.
get_values <- function(args) {
args[[.VAL_NAME]]
}
#' @title Check if \code{keys} and \code{values} named explicitly
#' @param arg_names Vector of names.
#' @return \code{TRUE} if both \code{keys} and \code{values} appear among \code{arg_names}.
all_explicit <- function(arg_names) {
all(c(.KEY_NAME, .VAL_NAME) %in% arg_names)
}
#' @title Check if \code{keys} and \code{values} named explicitly
#' @param arg_names Vector of names.
#' @return \code{TRUE} if both \code{keys} and \code{values} appear among \code{arg_names}.
any_explicit <- function(arg_names) {
any(c(.KEY_NAME, .VAL_NAME) %in% arg_names)
}
#' @title Check if all names are nonempty
#' @param arg_names Vector of names.
#' @return \code{TRUE} if all \code{arg_names} are nonempty, \code{FALSE} otherwise.
none_empty <- function(arg_names) {
(!is.null(arg_names)) && all(nchar(arg_names) > 0)
}
#' @title Check if any names are nonempty
#' @param arg_names Vector of names.
#' @return \code{TRUE} if any of the \code{arg_names} is empty, \code{FALSE} otherwise.
any_empty <- function(arg_names) {
is.null(arg_names) || any(nchar(arg_names) == 0)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.