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
bug an unexpected problem or unintended behavior

Comments

@earthcli
Copy link

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- commented Aug 15, 2017

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

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

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

@lionel-
Copy link
Member

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.

@lionel-
Copy link
Member

lionel- commented Aug 15, 2017

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

@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

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.

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
@hadley hadley added bug an unexpected problem or unintended behavior data frame labels Nov 2, 2017
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 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/

@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
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants