vars_pull: Select variable

Description Usage Arguments Value See Also Examples

Description

This function powers [pull()] and various functions of the tidyr package. It is similar to [vars_select()] but returns only one column name and has slightly different semantics: it allows negative numbers to select columns from the end.

Usage

1
vars_pull(vars, var = -1)

Arguments

var

A variable specified as: * a literal variable name * a positive integer, giving the position counting from the left * a negative integer, giving the position counting from the right.

The default returns the last column (on the assumption that's the column you've created most recently).

This argument is taken by expression and supports [quasiquotation][rlang::quasiquotation] (you can unquote column names and column positions).

Value

The selected column name as an unnamed string.

See Also

[pull()], [vars_select()]

Examples

1
2
3
4
5
6
7
8
9
# It takes its argument by expression:
vars_pull(letters, c)

# Negative numbers select from the end:
vars_pull(letters, -3)

# You can unquote variables:
var <- 10
vars_pull(letters, !! var)

lionel-/tidyselect documentation built on May 14, 2019, 9:23 p.m.