Debian Codegraph @

man/vars_pull.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/vars-pull.R
3 \name{vars_pull}
4 \alias{vars_pull}
5 \title{Select variable}
6 \usage{
7 vars_pull(
8 vars,
9 var = -1,
10 error_call = caller_env(),
11 error_arg = caller_arg(var)
12 )
13 }
14 \arguments{
15 \item{vars}{A character vector of existing column names.}
16
17 \item{var}{A variable specified as:
18 \itemize{
19 \item a literal variable name
20 \item a positive integer, giving the position counting from the left
21 \item a negative integer, giving the position counting from the right.
22 }
23
24 The default returns the last column (on the assumption that's the
25 column you've created most recently).
26
27 This argument is taken by expression and supports
28 \link[rlang:topic-inject]{quasiquotation} (you can unquote column
29 names and column locations).}
30
31 \item{error_call}{The execution environment of a currently
32 running function, e.g. \code{caller_env()}. The function will be
33 mentioned in error messages as the source of the error. See the
34 \code{call} argument of \code{\link[rlang:abort]{abort()}} for more information.}
35
36 \item{error_arg}{An argument name as a string. This argument
37 will be mentioned in error messages as the input that is at the
38 origin of a problem.}
39 }
40 \value{
41 The selected column name as an unnamed string.
42 }
43 \description{
44 This function powers \code{\link[dplyr:pull]{dplyr::pull()}} and various functions of the
45 tidyr package. It is similar to \code{\link[=vars_select]{vars_select()}} but returns only
46 one column name and has slightly different semantics: it allows
47 negative numbers to select columns from the end.
48 }
49 \examples{
50 # It takes its argument by expression:
51 vars_pull(letters, c)
52
53 # Negative numbers select from the end:
54 vars_pull(letters, -3)
55
56 # You can unquote variables:
57 var <- 10
58 vars_pull(letters, !!var)
59 }
60 \seealso{
61 \code{\link[dplyr:pull]{dplyr::pull()}}, \code{\link[=vars_select]{vars_select()}}
62 }
63 \keyword{internal}