#' Check for being a list, or a vector
#'
#' \code{is_simple_list} check if object is a list,
#' while not being a data.frame. \code{is_simple_vector}
#' checks if object is a vector, while not being array,
#' matrix, list etc.
#'
#' @param x an object.
#'
#' @examples
#'
#' is_simple_list(mtcars)
#' is_simple_list(list())
#' is_simple_list(as_lol(mtcars))
#'
#' is_simple_vector(letters[1:10])
#' is_simple_vector(as.list(1:10))
#'
#' @export
is_simple_list <- function(x) {
is.list(x) && !is.data.frame(x)
}
#' @rdname is_simple_list
#' @export
is_simple_vector <- function(x) {
is.atomic(x) && !is.array(x)
}
#' Check if object exists
#'
#' @param x object name.
#' @param env an environment.
#'
#' @examples
#'
#' lst <- list(
#' list(a = 1, b = "a"),
#' list(a = 2),
#' list(a = 3, b = NULL),
#' list(a = 4, b = NA)
#' )
#'
#' # show only the entries where "b" was declared
#'
#' lst %>%
#' filter(is_there(b))
#'
#' @export
is_there <- function(x, env = parent.frame()) {
exists(deparse(substitute(x)), envir = env)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.