dplyr::pull()
   get_help() docs


Description

The pull() function is part of the {dplyr} package, which is part of the {tidyverse}.

It is used to ‘pull out’ a given column from a tibble (data frame) into its own array. It’s like using the $ to access a column, except it can seamlessly integrate into {tidyverse} pipelines.

To use this function, you need to either first load the {dplyr} library, or always use the function with dplyr::pull() notation.

# Load the library
library(dplyr)
# Or, load the full tidyverse:
library(tidyverse)

# Or, use :: notation
dplyr::pull()

Conceptual Usage

tibble %>% 
  pull(column you want to pull out as array)

Examples

The examples below use the carnivores dataset. Learn more about this dataset with get_help("carnivores").

# Show the carnivores dataset
carnivores
## # A tibble: 9 × 4
##   name              genus        awake brainwt
##   <chr>             <fct>        <dbl>   <dbl>
## 1 Arctic fox        Vulpes        11.5  0.0445
## 2 Cheetah           Acinonyx      11.9 NA     
## 3 Dog               Canis         13.9  0.07  
## 4 Gray seal         Haliochoerus  17.8  0.325 
## 5 Jaguar            Panthera      13.6  0.157 
## 6 Lion              Panthera      10.5 NA     
## 7 Northern fur seal Callorhinus   15.3 NA     
## 8 Red fox           Vulpes        14.2  0.0504
## 9 Tiger             Panthera       8.2 NA


# Pull put the `genus` column into its own array
carnivores %>% 
  pull(genus)
## [1] Vulpes       Acinonyx     Canis        Haliochoerus Panthera     Panthera     Callorhinus 
## [8] Vulpes       Panthera    
## Levels: Acinonyx Callorhinus Canis Haliochoerus Panthera Vulpes


# Pull put the `brainwt` column into its own array
carnivores %>% 
  pull(brainwt)
## [1] 0.0445     NA 0.0700 0.3250 0.1570     NA     NA 0.0504     NA