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

Treat NULL as empty vectors in vars argument of _at() variants? #3023

Closed
earthcli opened this issue Aug 15, 2017 · 6 comments
Closed

Treat NULL as empty vectors in vars argument of _at() variants? #3023

earthcli opened this issue Aug 15, 2017 · 6 comments
Assignees
Labels

Comments

@earthcli
Copy link

@earthcli earthcli commented Aug 15, 2017

when the vars is NULL, mutate_each_ function will execute the functions on each column, while I expect do nothing!

mutate_each_(data.frame(x=1:5,y=3),funs(.*3),vars=NULL)

@lionel-
Copy link
Member

@lionel- lionel- commented Aug 15, 2017

These functions are deprecated. mutate_at() seems to do the right thing.

Loading

@lionel- lionel- closed this Aug 15, 2017
@earthcli
Copy link
Author

@earthcli earthcli commented Aug 15, 2017

Thanks!
but mutate_at also not work with .vars=NULL
mutate_at(data.frame(x=1:5,y=3),funs(.*3),.vars=NULL)

Error: .vars must be a character/numeric vector or a vars() object, not NULL

Loading

@lionel-
Copy link
Member

@lionel- lionel- commented Aug 15, 2017

It works with an empty vector, which you can create with vars(). We may want to treat NULL as empty vectors though, since we've been doing that in purrr's typed mappers in the last release.

Loading

@lionel-
Copy link
Member

@lionel- lionel- commented Aug 15, 2017

For now you can work around this with myvars %||% vars() if myvars might be NULL.

Loading

@lionel- lionel- reopened this Aug 15, 2017
@lionel- lionel- self-assigned this Aug 15, 2017
@lionel- lionel- changed the title not expect results of mutate_each_ for vars=NULL Treat NULL as empty vectors in vars argument of _at() variants? Aug 15, 2017
@earthcli
Copy link
Author

@earthcli earthcli commented Aug 15, 2017

Thank you very much!
I ask this because I have written some functions before. I will wait for the new version, otherwise I have to modify all my old functions.

Loading

lionel- added a commit to lionel-/dplyr that referenced this issue Aug 24, 2017
lionel- added a commit to lionel-/dplyr that referenced this issue Aug 24, 2017
@krlmlr krlmlr closed this in #3440 Mar 17, 2018
krlmlr added a commit that referenced this issue Mar 17, 2018
- Support `.vars = NULL` (same as `.vars = vars()`) in scoped verbs (#3023).
@lock
Copy link

@lock lock bot commented Sep 13, 2018

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

Loading

@lock lock bot locked and limited conversation to collaborators Sep 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants