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

All-NA argument in coalesce throws error unless all other arguments are type logical #3619

Closed
wdearden opened this issue May 29, 2018 · 4 comments

Comments

@wdearden
Copy link

Since the default type of NA is logical and coalesce calls check_type, if one argument is NA then coalesce will throw an error.

dplyr::coalesce(NA, 1)
# Error: Argument 2 must be type logical, not double
dplyr::coalesce(1, NA)
# Error: Argument 2 must be type double, not logical
dplyr::coalesce(NA, TRUE)
# [1] TRUE
dplyr::coalesce(NA_real_, 1)
# [1] 1

If this error is intentional, I can write a PR with a test to expect this error. If it's not, I can write a PR to skip type checking for all-NA arguments.

@hadley
Copy link
Member

hadley commented May 29, 2018

I'd rather leave this until we have a better general purpose system for coercing types. Then we'll fix all vector functions in one fell swoop.

@Williampio

This comment has been minimized.

@romainfrancois
Copy link
Member

#4389

@lock
Copy link

lock bot commented Dec 5, 2019

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 Dec 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants