Skip to content

vars_pull() and eval_select() work differently with all_of() #376

@DavisVaughan

Description

@DavisVaughan

See also tidyverse/dplyr#7720

Alternative solution would be to implement eval_pull() and deprecate vars_pull() #189

b <- "a"

data <- data.frame(a = 1, b = 2) 

tidyselect::vars_pull(
  names(data),
  tidyselect::all_of(b)
)
#> [1] "b"

tidyselect::eval_select(
  rlang::quo(tidyselect::all_of(b)),
  data
)
#> a 
#> 1

This shows up in dplyr's pull() and select() in weird ways

b <- "a"
dplyr::tibble(a = 1, b = 2) |> 
  dplyr::pull(dplyr::all_of(b))
#> [1] 2
dplyr::tibble(a = 1, b = 2) |> 
  dplyr::select(dplyr::all_of(b)) |>
  dplyr::pull()
#> [1] 1

I'm having trouble wrapping my mind around what is happening in the vars_pull() case

It's possible vars_pull() shouldn't allow all_of() or any_of() at all? That function is really for returning exactly 1 name, right? And it's likely that with all_of() and any_of() you can get >1? And it doesn't seem to be working right anyways (i.e. not pulling from the surrounding env)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions