Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support quoted variable in pull() #15

Closed
wants to merge 1 commit into from

Conversation

msberends
Copy link
Contributor

In dplyr, quoted variables also work in pull(), which makes it easy to combine with earlier set variables in code.

mtcars %>% dplyr::pull("mpg")
#>  [1] 21.0 21.0 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 17.8 16.4 17.3 15.2 10.4 10.4 14.7 32.4 30.4 33.9 21.5 15.5 15.2 13.3 19.2 27.3 26.0 30.4
#> [29] 15.8 19.7 15.0 21.4

Suggested change supports this.

In `dplyr`, quoted variables also work in `pull()`, which makes it easy to combine with earlier set variables in code.

```r
mtcars %>% dplyr::pull("mpg")
#>  [1] 21.0 21.0 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 17.8 16.4 17.3 15.2 10.4 10.4 14.7 32.4 30.4 33.9 21.5 15.5 15.2 13.3 19.2 27.3 26.0 30.4
#> [29] 15.8 19.7 15.0 21.4
```

Suggested change supports this.
@nathaneastwood
Copy link
Owner

I actually wonder whether this function should make use of select_positions() to be honest.

@nathaneastwood
Copy link
Owner

I remembered that I added the deparse_var() function for this kind of purpose. Thanks for the input @msberends.

@msberends
Copy link
Contributor Author

I'm afraid it does not work:

to_select <- "mpg"
mtcars %>% pull(to_select)

@nathaneastwood
Copy link
Owner

nathaneastwood commented May 7, 2020

I wouldn’t expect that to work to be honest. But

mtcars %>% pull("mpg")

Now does work

@nathaneastwood
Copy link
Owner

The reason it doesn't work (currently) is that pull is not aware of the context in which to_select is defined.

@nathaneastwood
Copy link
Owner

Actually, testing your PR, it does work. Let me take another look at it.

@nathaneastwood nathaneastwood reopened this May 7, 2020
@nathaneastwood nathaneastwood force-pushed the master branch 5 times, most recently from 63724b7 to a659c9c Compare May 9, 2020 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants