dplyr::pull

pull(.data, var = -1, name = NULL, ...)
Returns: vector · Updated April 5, 2026 · Tidyverse
dplyr r tidyverse data-wrangling

pull() extracts a single column from a data frame or tibble and returns it as a vector. It’s the pipe-friendly way to get a column out when you need a vector rather than a one-column tibble.

Signature

pull(.data, var = -1, name = NULL, ...)

Parameters

.data

A data frame, tibble, or lazy data frame (from dbplyr or dtplyr).

var

The column to extract. Accepts:

  • A bare column name: pull(var) — uses data masking (tidy evaluation)
  • A positive integer, giving the position counting from the left (1 = first column)
  • A negative integer, giving the position counting from the right (-1 = last column, -2 = second-to-last)

Defaults to -1 — the last column.

name

An optional column whose values become names in the output vector:

starwars |> pull(height, name = name)
#>        Luke Skywalker                 C-3PO                 R2-D2 
#>                   172                   167                    96

If NULL (the default), the output is unnamed.

Passed to methods for other classes (e.g., dbplyr remote tables).

Return Value

A vector. The type depends on the column — numeric column returns numeric vector, character column returns character vector. Unlike $, pull() always returns a vector, never a list or data frame.

Default Behavior

pull() defaults to the last column (var = -1). This is useful when you’ve just created a new column with mutate() and want to extract it immediately:

df |>
  mutate(total = a + b + c) |>
  pull()
#>  [1] 10 18 24 28 30 30 28 24 18 10

The mutate() call creates the total column as the last column, then pull() extracts it as a vector without needing to refer to it by name.

Extracting by Position

You can index from the left or right:

# First column
df |> pull(1)

# Second column from the right
df |> pull(-2)

Unlike [[]] indexing, negative integers consistently count from the right.

Producing Named Vectors

Use the name argument to create a named vector, where one column’s values become the names:

# Height in cm, named by character
starwars |> pull(height, name = name)
#>        Luke Skywalker                 C-3PO                 R2-D2 
#>                   172                   167                    96

This is handy when you need a lookup vector:

height_map <- starwars |> pull(height, name = name)
height_map["Luke Skywalker"]
#> Luke Skywalker 
#>             172

pull vs $

pull() and $ both extract a column, but they differ in two ways:

pull()$
Return typeAlways a vectorVector or list (for list-columns)
Pipe usageDesigned for pipesRequires the data on the left
Data maskingYes — bare names workNo — needs df$x

In a pipe, df |> pull(x) reads more naturally than df$x or df[["x"]].

See Also