Skip to content

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

Closed

Description

@gorcha

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)

Activity

  1. added a commit that references this issue on Apr 27, 2021
    7c83028
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions