Skip to content

rlang 0.4.3

Choose a tag to compare

@lionel- lionel- released this 25 Jan 10:29
  • You can now use glue syntax to unquote on the LHS of :=. This
    syntax is automatically available in all functions taking dots with
    list2() and enquos(), and thus most of the tidyverse. Note that
    if you use the glue syntax in an R package, you need to import glue.

    A single pair of braces triggers normal glue interpolation:

    df <- data.frame(x = 1:3)
    
    suffix <- "foo"
    df %>% dplyr::mutate("var_{suffix}" := x * 2)
    #>   x var_foo
    #> 1 1       2
    #> 2 2       4
    #> 3 3       6

    Using a pair of double braces is for labelling a function argument.
    Technically, this is shortcut for "{as_label(enquo(arg))}". The
    syntax is similar to the curly-curly syntax for interpolating
    function arguments:

    my_wrapper <- function(data, var, suffix = "foo") {
      data %>% dplyr::mutate("{{ var }}_{suffix}" := {{ var }} * 2)
    }
    df %>% my_wrapper(x)
    #>   x x_foo
    #> 1 1     2
    #> 2 2     4
    #> 3 3     6
    
    df %>% my_wrapper(sqrt(x))
    #>   x sqrt(x)_foo
    #> 1 1    2.000000
    #> 2 2    2.828427
    #> 3 3    3.464102
  • Fixed a bug in magrittr backtraces that caused duplicate calls to
    appear in the trace.

  • Fixed a bug in magrittr backtraces that caused wrong call indices.

  • Empty backtraces are no longer shown when rlang_backtrace_on_error
    is set.

  • The tidy eval .env pronoun is now exported for documentation
    purposes.

  • warn() and abort() now check that either class or message
    was supplied. inform() allows sending empty message as it is
    occasionally useful for building user output incrementally.

  • flatten() fails with a proper error when input can't be flattened (#868, #885).

  • inform() now consistently appends a final newline to the message
    (#880).

  • cnd_body.default() is now properly registered.

  • cnd_signal() now uses the same approach as abort() to save
    unhandled errors to last_error().

  • Parsable constants like NaN and NA_integer_ are now deparsed by
    expr_deparse() in their parsable form (#890).

  • Infix operators now stick to their LHS when deparsed by
    expr_deparse() (#890).