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

min and max throw an error if na.rm = TRUE and all values are NA #1357

Closed
gorcha opened this issue Apr 9, 2021 · 0 comments · Fixed by #1358
Closed

min and max throw an error if na.rm = TRUE and all values are NA #1357

gorcha opened this issue Apr 9, 2021 · 0 comments · Fixed by #1358

Comments

@gorcha
Copy link
Contributor

gorcha commented Apr 9, 2021

From tidyverse/haven#528 - min() and max() throw an error if all values are NA and na.rm = TRUE.
The base R versions return Inf or -Inf respectively.

They should possibly return NA instead of Inf/-Inf, see #1004.

min(NA_real_, na.rm = TRUE)
#> Warning in min(NA_real_, na.rm = TRUE): no non-missing arguments to min;
#> returning Inf
#> [1] Inf
vctrs:::min.vctrs_vctr(NA_real_, na.rm = TRUE)
#> Error in idx[[1]]: subscript out of bounds

max(NA_real_, na.rm = TRUE)
#> Warning in max(NA_real_, na.rm = TRUE): no non-missing arguments to max;
#> returning -Inf
#> [1] -Inf
vctrs:::max.vctrs_vctr(NA_real_, na.rm = TRUE)
#> Error in idx[[1]]: subscript out of bounds

Created on 2021-04-09 by the reprex package (v1.0.0)

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 a pull request may close this issue.

1 participant