Skip to contents

Nearly identical to rlang::exprs_auto_name(), but rlang::as_name() is used instead of rlang::as_label(). For String items the string will returned without wrapping in double quotes. The naming of functions and formulas is not optimal, it is better to manually name theme.

Usage

auto_name(exprs)

Arguments

exprs

A list of expressions.

Value

A named list of expressions

Examples

funs <- list(
  "mean",
  function(x) stats::quantile(x, probs = 0.95),
  ~ stats::quantile(., probs = 0.95),
  q95 = function(x) stats::quantile(x, probs = 0.95)
)

auto_name(funs)
#> $mean
#> [1] "mean"
#> 
#> $`function (x) ...`
#> function(x) stats::quantile(x, probs = 0.95)
#> <environment: 0x000002df7e3311b0>
#> 
#> $`~stats::quantile(., probs = 0.95)`
#> ~stats::quantile(., probs = 0.95)
#> <environment: 0x000002df7e3311b0>
#> 
#> $q95
#> function(x) stats::quantile(x, probs = 0.95)
#> <environment: 0x000002df7e3311b0>
#> 

# exprs_autoname adds double quotes to strings
rlang::exprs_auto_name(funs)
#> $`"mean"`
#> [1] "mean"
#> 
#> $`<fn>`
#> function(x) stats::quantile(x, probs = 0.95)
#> <environment: 0x000002df7e3311b0>
#> 
#> $`~stats::quantile(., probs = 0.95)`
#> ~stats::quantile(., probs = 0.95)
#> <environment: 0x000002df7e3311b0>
#> 
#> $q95
#> function(x) stats::quantile(x, probs = 0.95)
#> <environment: 0x000002df7e3311b0>
#>