dplyr::pull()

Function of the Week: dplyr::pull()

Function of the Week

Submit both the .Rmd and the .html files.

Function: Pull()

In this document, I will introduce the pull() function, which is within the tidyverse package. I will show what it’s for, what it does and doesn’t do.

library(tidyverse)
library(palmerpenguins)
data(penguins)
print(head(penguins))
## # A tibble: 6 x 8
##   species island bill_length_mm bill_depth_mm flipper_length_~ body_mass_g sex  
##   <fct>   <fct>           <dbl>         <dbl>            <int>       <int> <fct>
## 1 Adelie  Torge~           39.1          18.7              181        3750 male 
## 2 Adelie  Torge~           39.5          17.4              186        3800 fema~
## 3 Adelie  Torge~           40.3          18                195        3250 fema~
## 4 Adelie  Torge~           NA            NA                 NA          NA <NA> 
## 5 Adelie  Torge~           36.7          19.3              193        3450 fema~
## 6 Adelie  Torge~           39.3          20.6              190        3650 male 
## # ... with 1 more variable: year <int>

What is it for?

What this function does and how to apply it within the dataset ‘penguins’.

This is a function in tidyverse that you can use to extract columns.

The value that is created from using pull() is a vector, which prints in the same length (amount of values) as is in the data frame.

Example 1: calling variable name

pull(data, var name)

pull(penguins, species)
##   [1] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##   [8] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [15] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [22] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [29] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [36] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [43] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [50] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [57] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [64] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [71] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [78] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [85] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [92] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [99] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
## [106] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
## [113] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
## [120] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
## [127] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
## [134] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
## [141] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
## [148] Adelie    Adelie    Adelie    Adelie    Adelie    Gentoo    Gentoo   
## [155] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [162] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [169] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [176] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [183] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [190] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [197] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [204] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [211] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [218] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [225] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [232] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [239] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [246] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [253] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [260] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [267] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [274] Gentoo    Gentoo    Gentoo    Chinstrap Chinstrap Chinstrap Chinstrap
## [281] Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap
## [288] Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap
## [295] Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap
## [302] Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap
## [309] Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap
## [316] Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap
## [323] Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap
## [330] Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap
## [337] Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap
## [344] Chinstrap
## Levels: Adelie Chinstrap Gentoo
# shows all values, shows the 3 levels of the factored variable at the very end

Example 2: calling variable index, positive integer

pull(data, var +#)

pull(penguins, 2)
##   [1] Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen
##   [8] Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen
##  [15] Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen Biscoe   
##  [22] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
##  [29] Biscoe    Biscoe    Dream     Dream     Dream     Dream     Dream    
##  [36] Dream     Dream     Dream     Dream     Dream     Dream     Dream    
##  [43] Dream     Dream     Dream     Dream     Dream     Dream     Dream    
##  [50] Dream     Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
##  [57] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
##  [64] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Torgersen Torgersen
##  [71] Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen
##  [78] Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen
##  [85] Dream     Dream     Dream     Dream     Dream     Dream     Dream    
##  [92] Dream     Dream     Dream     Dream     Dream     Dream     Dream    
##  [99] Dream     Dream     Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
## [106] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
## [113] Biscoe    Biscoe    Biscoe    Biscoe    Torgersen Torgersen Torgersen
## [120] Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen
## [127] Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen Dream    
## [134] Dream     Dream     Dream     Dream     Dream     Dream     Dream    
## [141] Dream     Dream     Dream     Dream     Dream     Dream     Dream    
## [148] Dream     Dream     Dream     Dream     Dream     Biscoe    Biscoe   
## [155] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
## [162] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
## [169] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
## [176] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
## [183] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
## [190] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
## [197] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
## [204] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
## [211] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
## [218] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
## [225] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
## [232] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
## [239] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
## [246] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
## [253] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
## [260] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
## [267] Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe   
## [274] Biscoe    Biscoe    Biscoe    Dream     Dream     Dream     Dream    
## [281] Dream     Dream     Dream     Dream     Dream     Dream     Dream    
## [288] Dream     Dream     Dream     Dream     Dream     Dream     Dream    
## [295] Dream     Dream     Dream     Dream     Dream     Dream     Dream    
## [302] Dream     Dream     Dream     Dream     Dream     Dream     Dream    
## [309] Dream     Dream     Dream     Dream     Dream     Dream     Dream    
## [316] Dream     Dream     Dream     Dream     Dream     Dream     Dream    
## [323] Dream     Dream     Dream     Dream     Dream     Dream     Dream    
## [330] Dream     Dream     Dream     Dream     Dream     Dream     Dream    
## [337] Dream     Dream     Dream     Dream     Dream     Dream     Dream    
## [344] Dream    
## Levels: Biscoe Dream Torgersen
# shows all values, shows the 3 levels of the factored variable at the very end

Example 3: calling variable index, negative integer

pull(data, var -#)

pull(penguins, -2) #2nd column from the right side
##   [1] male   female female <NA>   female male   female male   <NA>   <NA>  
##  [11] <NA>   <NA>   female male   male   female female male   female male  
##  [21] female male   female male   male   female male   female female male  
##  [31] female male   female male   female male   male   female female male  
##  [41] female male   female male   female male   male   <NA>   female male  
##  [51] female male   female male   female male   female male   female male  
##  [61] female male   female male   female male   female male   female male  
##  [71] female male   female male   female male   female male   female male  
##  [81] female male   female male   female male   male   female male   female
##  [91] female male   female male   female male   female male   female male  
## [101] female male   female male   female male   female male   female male  
## [111] female male   female male   female male   female male   female male  
## [121] female male   female male   female male   female male   female male  
## [131] female male   female male   female male   female male   female male  
## [141] female male   female male   female male   male   female female male  
## [151] female male   female male   female male   male   female female male  
## [161] female male   female male   female male   female male   female male  
## [171] female male   male   female female male   female male   <NA>   male  
## [181] female male   male   female female male   female male   female male  
## [191] female male   female male   female male   male   female female male  
## [201] female male   female male   female male   female male   female male  
## [211] female male   female male   female male   female male   <NA>   male  
## [221] female male   female male   male   female female male   female male  
## [231] female male   female male   female male   female male   female male  
## [241] female male   female male   female male   female male   male   female
## [251] female male   female male   female male   <NA>   male   female male  
## [261] female male   female male   female male   female male   <NA>   male  
## [271] female <NA>   female male   female male   female male   male   female
## [281] male   female female male   female male   female male   female male  
## [291] female male   male   female female male   female male   female male  
## [301] female male   female male   female male   female male   female male  
## [311] male   female female male   female male   male   female male   female
## [321] female male   female male   male   female female male   female male  
## [331] female male   female male   male   female male   female female male  
## [341] female male   male   female
## Levels: female male
# shows all values, shows the 2 levels of the factored variable at the very end

Example 4: using a pipe to save a value as a vector

x1<- data %>% pull(column)

body_mass_vector <- penguins %>% pull(body_mass_g)
body_mass_vector # shows all values from the dataframe
##   [1] 3750 3800 3250   NA 3450 3650 3625 4675 3475 4250 3300 3700 3200 3800 4400
##  [16] 3700 3450 4500 3325 4200 3400 3600 3800 3950 3800 3800 3550 3200 3150 3950
##  [31] 3250 3900 3300 3900 3325 4150 3950 3550 3300 4650 3150 3900 3100 4400 3000
##  [46] 4600 3425 2975 3450 4150 3500 4300 3450 4050 2900 3700 3550 3800 2850 3750
##  [61] 3150 4400 3600 4050 2850 3950 3350 4100 3050 4450 3600 3900 3550 4150 3700
##  [76] 4250 3700 3900 3550 4000 3200 4700 3800 4200 3350 3550 3800 3500 3950 3600
##  [91] 3550 4300 3400 4450 3300 4300 3700 4350 2900 4100 3725 4725 3075 4250 2925
## [106] 3550 3750 3900 3175 4775 3825 4600 3200 4275 3900 4075 2900 3775 3350 3325
## [121] 3150 3500 3450 3875 3050 4000 3275 4300 3050 4000 3325 3500 3500 4475 3425
## [136] 3900 3175 3975 3400 4250 3400 3475 3050 3725 3000 3650 4250 3475 3450 3750
## [151] 3700 4000 4500 5700 4450 5700 5400 4550 4800 5200 4400 5150 4650 5550 4650
## [166] 5850 4200 5850 4150 6300 4800 5350 5700 5000 4400 5050 5000 5100 4100 5650
## [181] 4600 5550 5250 4700 5050 6050 5150 5400 4950 5250 4350 5350 3950 5700 4300
## [196] 4750 5550 4900 4200 5400 5100 5300 4850 5300 4400 5000 4900 5050 4300 5000
## [211] 4450 5550 4200 5300 4400 5650 4700 5700 4650 5800 4700 5550 4750 5000 5100
## [226] 5200 4700 5800 4600 6000 4750 5950 4625 5450 4725 5350 4750 5600 4600 5300
## [241] 4875 5550 4950 5400 4750 5650 4850 5200 4925 4875 4625 5250 4850 5600 4975
## [256] 5500 4725 5500 4700 5500 4575 5500 5000 5950 4650 5500 4375 5850 4875 6000
## [271] 4925   NA 4850 5750 5200 5400 3500 3900 3650 3525 3725 3950 3250 3750 4150
## [286] 3700 3800 3775 3700 4050 3575 4050 3300 3700 3450 4400 3600 3400 2900 3800
## [301] 3300 4150 3400 3800 3700 4550 3200 4300 3350 4100 3600 3900 3850 4800 2700
## [316] 4500 3950 3650 3550 3500 3675 4450 3400 4300 3250 3675 3325 3950 3600 4050
## [331] 3350 3450 3250 4050 3800 3525 3950 3650 3650 4000 3400 3775 4100 3775

Example 5: pull more than 1 column at a time

data %>% pull(column [dbl], column [chr])

penguins %>% pull(body_mass_g, island)
## Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen 
##      3750      3800      3250        NA      3450      3650      3625      4675 
## Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen 
##      3475      4250      3300      3700      3200      3800      4400      3700 
## Torgersen Torgersen Torgersen Torgersen    Biscoe    Biscoe    Biscoe    Biscoe 
##      3450      4500      3325      4200      3400      3600      3800      3950 
##    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe     Dream     Dream 
##      3800      3800      3550      3200      3150      3950      3250      3900 
##     Dream     Dream     Dream     Dream     Dream     Dream     Dream     Dream 
##      3300      3900      3325      4150      3950      3550      3300      4650 
##     Dream     Dream     Dream     Dream     Dream     Dream     Dream     Dream 
##      3150      3900      3100      4400      3000      4600      3425      2975 
##     Dream     Dream    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe 
##      3450      4150      3500      4300      3450      4050      2900      3700 
##    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe 
##      3550      3800      2850      3750      3150      4400      3600      4050 
##    Biscoe    Biscoe    Biscoe    Biscoe Torgersen Torgersen Torgersen Torgersen 
##      2850      3950      3350      4100      3050      4450      3600      3900 
## Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen 
##      3550      4150      3700      4250      3700      3900      3550      4000 
## Torgersen Torgersen Torgersen Torgersen     Dream     Dream     Dream     Dream 
##      3200      4700      3800      4200      3350      3550      3800      3500 
##     Dream     Dream     Dream     Dream     Dream     Dream     Dream     Dream 
##      3950      3600      3550      4300      3400      4450      3300      4300 
##     Dream     Dream     Dream     Dream    Biscoe    Biscoe    Biscoe    Biscoe 
##      3700      4350      2900      4100      3725      4725      3075      4250 
##    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe 
##      2925      3550      3750      3900      3175      4775      3825      4600 
##    Biscoe    Biscoe    Biscoe    Biscoe Torgersen Torgersen Torgersen Torgersen 
##      3200      4275      3900      4075      2900      3775      3350      3325 
## Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen Torgersen 
##      3150      3500      3450      3875      3050      4000      3275      4300 
## Torgersen Torgersen Torgersen Torgersen     Dream     Dream     Dream     Dream 
##      3050      4000      3325      3500      3500      4475      3425      3900 
##     Dream     Dream     Dream     Dream     Dream     Dream     Dream     Dream 
##      3175      3975      3400      4250      3400      3475      3050      3725 
##     Dream     Dream     Dream     Dream     Dream     Dream     Dream     Dream 
##      3000      3650      4250      3475      3450      3750      3700      4000 
##    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe 
##      4500      5700      4450      5700      5400      4550      4800      5200 
##    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe 
##      4400      5150      4650      5550      4650      5850      4200      5850 
##    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe 
##      4150      6300      4800      5350      5700      5000      4400      5050 
##    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe 
##      5000      5100      4100      5650      4600      5550      5250      4700 
##    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe 
##      5050      6050      5150      5400      4950      5250      4350      5350 
##    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe 
##      3950      5700      4300      4750      5550      4900      4200      5400 
##    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe 
##      5100      5300      4850      5300      4400      5000      4900      5050 
##    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe 
##      4300      5000      4450      5550      4200      5300      4400      5650 
##    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe 
##      4700      5700      4650      5800      4700      5550      4750      5000 
##    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe 
##      5100      5200      4700      5800      4600      6000      4750      5950 
##    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe 
##      4625      5450      4725      5350      4750      5600      4600      5300 
##    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe 
##      4875      5550      4950      5400      4750      5650      4850      5200 
##    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe 
##      4925      4875      4625      5250      4850      5600      4975      5500 
##    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe 
##      4725      5500      4700      5500      4575      5500      5000      5950 
##    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe    Biscoe 
##      4650      5500      4375      5850      4875      6000      4925        NA 
##    Biscoe    Biscoe    Biscoe    Biscoe     Dream     Dream     Dream     Dream 
##      4850      5750      5200      5400      3500      3900      3650      3525 
##     Dream     Dream     Dream     Dream     Dream     Dream     Dream     Dream 
##      3725      3950      3250      3750      4150      3700      3800      3775 
##     Dream     Dream     Dream     Dream     Dream     Dream     Dream     Dream 
##      3700      4050      3575      4050      3300      3700      3450      4400 
##     Dream     Dream     Dream     Dream     Dream     Dream     Dream     Dream 
##      3600      3400      2900      3800      3300      4150      3400      3800 
##     Dream     Dream     Dream     Dream     Dream     Dream     Dream     Dream 
##      3700      4550      3200      4300      3350      4100      3600      3900 
##     Dream     Dream     Dream     Dream     Dream     Dream     Dream     Dream 
##      3850      4800      2700      4500      3950      3650      3550      3500 
##     Dream     Dream     Dream     Dream     Dream     Dream     Dream     Dream 
##      3675      4450      3400      4300      3250      3675      3325      3950 
##     Dream     Dream     Dream     Dream     Dream     Dream     Dream     Dream 
##      3600      4050      3350      3450      3250      4050      3800      3525 
##     Dream     Dream     Dream     Dream     Dream     Dream     Dream     Dream 
##      3950      3650      3650      4000      3400      3775      4100      3775
# it has to be in the order of numeric, character and then prints matched observations

Is pull() helpful?

Is this useful for work or is it irrelevant?

Pros:

dplyr::pull() can be worked with or without quotes, however with other similar functions like purrr:pluck(), you need to use quotes around the variables you’re calling.

Easy to read and understand for non-coders or beginners.

Seeing pull(data, var) is nicer on the eyes than other variations like data$var and any other type of variation that uses different types of characters within the code.

Cons:

From digging around on the internet a bit, through forums and articles, it seems like pull() overall isn’t really that functional for more complex wrangling.

Cannot use as many types of “verbs” as select() does.
Select() offers “starts_with()”, “ends_with()”, “contains()”, and “everything()” which can be easier to create tibbles with columns that all contain similar values.

  • Example in penguins data:

    • can utilize “ends_with()” to pull columns with the same measurements

    • bill_length_mm, bill_depth_mm, flipper_length_mm

Comparing to select(), pull() creates a vector, while select() creates a tibble.

penguins %>% pull(species)
##   [1] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##   [8] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [15] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [22] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [29] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [36] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [43] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [50] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [57] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [64] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [71] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [78] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [85] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [92] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
##  [99] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
## [106] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
## [113] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
## [120] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
## [127] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
## [134] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
## [141] Adelie    Adelie    Adelie    Adelie    Adelie    Adelie    Adelie   
## [148] Adelie    Adelie    Adelie    Adelie    Adelie    Gentoo    Gentoo   
## [155] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [162] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [169] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [176] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [183] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [190] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [197] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [204] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [211] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [218] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [225] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [232] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [239] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [246] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [253] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [260] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [267] Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo    Gentoo   
## [274] Gentoo    Gentoo    Gentoo    Chinstrap Chinstrap Chinstrap Chinstrap
## [281] Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap
## [288] Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap
## [295] Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap
## [302] Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap
## [309] Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap
## [316] Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap
## [323] Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap
## [330] Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap
## [337] Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap Chinstrap
## [344] Chinstrap
## Levels: Adelie Chinstrap Gentoo
penguins %>% select(species)
## # A tibble: 344 x 1
##    species
##    <fct>  
##  1 Adelie 
##  2 Adelie 
##  3 Adelie 
##  4 Adelie 
##  5 Adelie 
##  6 Adelie 
##  7 Adelie 
##  8 Adelie 
##  9 Adelie 
## 10 Adelie 
## # ... with 334 more rows

Select() appears to be easier to manipulate and sort through, as well as the verbs that it offers.
Pull() doesn’t offer much but can be a simple way to skim over values or observations from specific columns.

Conclusion

Pull() is good for beginners, it’s simple, it’s readable, it’s a good way to dip your toes into data wrangling but there’s not much you can do with it.

It is often overlooked for being so bland;
This site states;

“Main data manipulation functions”

There are 8 fundamental data verbs/functions which are;

  • filter(): Pick rows (observations/samples) based on their values
  • distinct(): Remove duplicate rows
  • arrange(): Reorder the rows
  • select(): Select columns (variables) by their names
  • rename(): Rename columns
  • mutate() and transmutate(): Add/create new variables
  • summarise(): Compute statistical summaries (e.g., computing the mean or the sum)

Pull is not included probably because the results are too uneventful and bland.