File: utils-tidy-eval.R

package info (click to toggle)
r-bioc-decoupler 2.12.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,612 kB
  • sloc: makefile: 5
file content (51 lines) | stat: -rw-r--r-- 2,180 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#' Tidy eval helpers
#'
#' @description
#'
#' * [rlang::sym()] creates a symbol from a string and
#'   [`syms()`][rlang::sym] creates a list of symbols from a
#'   character vector.
#'
#' * [`enquo()`][rlang::nse-defuse] and
#'   [`enquos()`][rlang::nse-defuse] delay the execution of one or
#'   several function arguments. `enquo()` returns a single quoted
#'   expression, which is like a blueprint for the delayed computation.
#'   `enquos()` returns a list of such quoted expressions.
#'
#' * [`expr()`][rlang::nse-defuse] quotes a new expression _locally_. It
#'   is mostly useful to build new expressions around arguments
#'   captured with [enquo()] or [enquos()]:
#'   `expr(mean(!!enquo(arg), na.rm = TRUE))`.
#'
#' * [rlang::as_name()] transforms a quoted variable name
#'   into a string. Supplying something else than a quoted variable
#'   name is an error.
#'
#'   That's unlike [rlang::as_label()] which also returns
#'   a single string but supports any kind of R object as input,
#'   including quoted function calls and vectors. Its purpose is to
#'   summarise that object into a single label. That label is often
#'   suitable as a default name.
#'
#'   If you don't know what a quoted expression contains (for instance
#'   expressions captured with `enquo()` could be a variable
#'   name, a call to a function, or an unquoted constant), then use
#'   `as_label()`. If you know you have quoted a simple variable
#'   name, or would like to enforce this, use `as_name()`.
#'
#' To learn more about tidy eval and how to use these tools, visit
#' <https://tidyeval.tidyverse.org> and the
#' [Metaprogramming section](https://adv-r.hadley.nz/metaprogramming.html) of
#' [Advanced R](https://adv-r.hadley.nz).
#'
#' @md
#' @name tidyeval
#' @keywords internal
#' @importFrom rlang expr enquo enquos sym syms .data := as_name as_label quo_is_null quo_is_missing abort exec
#' @aliases expr enquo enquos sym syms .data := as_name as_label quo_is_null quo_is_missing abort exec
#' @export expr enquo enquos sym syms .data := as_name as_label quo_is_null quo_is_missing abort exec
#' @examples
#' if (FALSE) {
#'     help("nse-defuse", package = "rlang")
#' }
NULL