Skip to contents

This function tries to determine the name of a variable passed to a function.

Usage

variable_name(variable, fallback = "unnamed")

Arguments

variable

[any]
Any object.

fallback

[character(1)]
A fallback name if for some reason the actual variable name (which must be a single character) cannot be determined.

Value

A character, the variable name.

See also

Examples

variable_name(a)
#> [1] "a"
f <- function(x) variable_name(x)
f(x = a)
#> [1] "a"