R: Defuse function arguments with glue

englue {rlang} | R Documentation

## Defuse function arguments with glue

### Description

`englue()` creates a string with the glue operators `{` and `{{`. These operators are normally used to inject names within dynamic dots. `englue()` makes them available anywhere within a function.

`englue()` must be used inside a function. `englue("{{ var }}")` defuses the argument `var` and transforms it to a string using the default name operation.

### Usage

    englue(x)

### Arguments

`x` | A string to interpolate with glue operators.

### Details

`englue("{{ var }}")` is equivalent to `as_label(enquo(var))`. It defuses `arg` and transforms the expression to a string with `as_label()`.

In dynamic dots, using only `{` is allowed. In `englue()` you must use `{{` at least once. Use `glue::glue()` for simple interpolation.

Before using `englue()` in a package, first ensure that glue is installed by adding it to your `Imports:` section.

    usethis::use_package("glue", "Imports")

### See Also

- Injecting with !!, !!!, and glue syntax

### Examples

    g <- function(var) englue("{{ var }}")
    g(cyl)
    g(1 + 1)
    g(!!letters)

    # These are equivalent to
    as_label(quote(cyl))
    as_label(quote(1 + 1))
    as_label(letters)

[Package rlang version 1.0.2 Index]