Skip to content

[R] Let na.rm of mean() support removing NaN as in base R #44089

@psychelzh

Description

@psychelzh

Describe the enhancement requested

See the following example. In base R na.rm will also remove NaN values, because of the fact that is.na(NaN) == TRUE.

suppressPackageStartupMessages(library(dplyr))
data.frame(x = c(1, 2, NaN)) |> 
  arrow::as_arrow_table() |>
  summarise(x_avg = mean(x, na.rm = TRUE)) |> 
  collect()
#> # A tibble: 1 × 1
#>   x_avg
#>   <dbl>
#> 1   NaN
data.frame(x = c(1, 2, NaN)) |> 
  summarise(x_avg = mean(x, na.rm = TRUE))
#>   x_avg
#> 1   1.5

Created on 2024-09-12 with reprex v2.1.0

Component(s)

R

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions