R/vname.R

Defines functions vname

Documented in vname

#' @title Lookup a variable name
#' @description
#' Tries to heuristically determine the variable name of \code{x} in the parent frame
#' with a combination of \code{\link[base]{deparse}} and \code{\link[base]{substitute}}.
#' Used for checkmate's error messages.
#' @param x [ANY]\cr
#'   Object.
#' @return [\code{character(1)}] Variable name.
#' @export
vname = function(x) {
  paste0(deparse(eval.parent(substitute(substitute(x))), width.cutoff = 500L), collapse = "\n")
}

Try the checkmate package in your browser

Any scripts or data that you put into this service are public.

checkmate documentation built on Sept. 11, 2024, 8:40 p.m.