expr_text() turns the expression into a single string, which
might be multi-line. expr_name() is suitable for formatting
names. It works best with symbols and scalar types, but also
accepts calls. expr_label() formats the expression nicely for use
in messages.
expr_label(expr) expr_name(expr) expr_text(expr, width = 60L, nlines = Inf)
| expr | An expression to labellise. |
|---|---|
| width | Width of each line. |
| nlines | Maximum number of lines to extract. |
These functions are in the questioning stage because they are
redundant with the quo_ variants and do not handle quosures.
# 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\""#> [1] "`x`"#> [1] "`a + b + c`"#> [1] "`foo(...)`"