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

Improve error message when a function is supplied quoted to funs() #3368

Closed
lionel- opened this issue Feb 20, 2018 · 3 comments
Closed

Improve error message when a function is supplied quoted to funs() #3368

lionel- opened this issue Feb 20, 2018 · 3 comments

Comments

@lionel-
Copy link
Member

@lionel- lionel- commented Feb 20, 2018

See r-lib/rlang#411:

library("dplyr")
packageVersion("dplyr")
# [1] ‘0.7.4’
packageVersion("rlang")
# [1] ‘0.2.0’
mp <- c("cyl" = "cylinders", "gear" = "gears")
rename_at(.tbl = datasets::mtcars, 
          .vars = names(mp), 
          .funs = funs(function(si) { mp[si] }))
# Error: All arguments must be named 
@lionel- lionel- self-assigned this Feb 20, 2018
@lionel-
Copy link
Member Author

@lionel- lionel- commented Feb 20, 2018

Or should we treat quoted functions specially? The UI of funs() is weird because it supports calls as in funs(my_function(.)) and symbols as in funs(my_function). The latter might suggest you should be able to pass a lambda function as well, e.g. funs(function(x) do(x)). It might make the UI a bit more predictable if we special-case calls to function.

I think ideally funs() would only support calls and not symbols then there would be no ambiguity. Of course this is now too late to change.

cc @JohnMount @hadley

@hadley
Copy link
Member

@hadley hadley commented Feb 21, 2018

I think we need to rework/replace funs with a version that does not quote, but instead accepts purrr style anonymous functions. I've been trying to teach funs() and it's currently just too confusing.

@krlmlr krlmlr closed this in #3435 Mar 16, 2018
krlmlr added a commit that referenced this issue Mar 16, 2018
* Show clear error message for bad arguments to `funs()` (#3368).
krlmlr added a commit that referenced this issue Mar 16, 2018
* Show clear error message for bad arguments to `funs()` (#3368).

* Improved documentation for `funs()` (#3094).

* Compute variable names for joins in R (#3430).

* Hybrid evaluation simplifies `dplyr::foo` to `foo` (#3309).

* `bind_cols()` handles unnamed list (#3402).
@lock
Copy link

@lock lock bot commented Sep 12, 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 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants