dplyr (version 0.7.8)

pull: Pull out a single variable

Description

This works like [[ for local data frames, and automatically collects before indexing for remote data tables.

Usage

pull(.data, var = -1)

Arguments

.data

A table of data

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 (you can unquote column names and column positions).

Examples

Run this code
# NOT RUN {
mtcars %>% pull(-1)
mtcars %>% pull(1)
mtcars %>% pull(cyl)

# Also works for remote sources
if (requireNamespace("dbplyr", quietly = TRUE)) {
df <- dbplyr::memdb_frame(x = 1:10, y = 10:1, .name = "pull-ex")
df %>%
  mutate(z = x * y) %>%
  pull()
}

# }

Run the code above in your browser using DataCamp Workspace