Examples for 'rlang::expr_label'


Turn an expression to a label

Aliases: expr_label expr_name expr_text

Keywords: internal

### ** Examples

# To labellise a function argument, first capture it with
# substitute():
fn <- function(x) expr_label(substitute(x))
fn(x:y)
[1] "`x:y`"
# Strings are encoded
expr_label("a\nb")
[1] "\"a\\nb\""
# Names and expressions are quoted with ``
expr_label(quote(x))
[1] "`x`"
expr_label(quote(a + b + c))
[1] "`a + b + c`"
# Long expressions are collapsed
expr_label(quote(foo({
  1 + 2
  print(x)
})))
[1] "`foo(...)`"

[Package rlang version 1.1.4 Index]