#' Check if all elements of an object are named
#'
#' Check if all elements of an object have non-empty names.
#'
#' @param x `[any]`
#'
#' An object.
#'
#' @returns A `logical(1)`.
#'
#' @details This function first checks if the underlying `names` attribute of
#' `x` is `NULL`. If it is not, then it checks if all its elements are
#' non-empty strings (`character(1)` values __not__ equal to `""`).
#'
#' @examples
#' x <- c(a = 1, b = 2, 3)
#' y <- c(a = 1, b = 2, c = 3)
#'
#' has_names(x) # FALSE
#' has_names(y) # TRUE
#'
#' @export
has_names <- function(x)
{
nms <- names(x)
return(!is_nul(nms) && all(nzchar(nms)))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.