Skip to content

Not ignoring NAs with 64-bit integers and grouped operations? #4444

@go-see

Description

@go-see

Problem

When I attempt to find the grouped minima of a 64-bit integer (using na.rm = T), it appears as though data.table is ignores the na.rm = T. This does not happen for other grouped operations on 64-bit integers (e.g., max or sum).

Minimal reproducible example

# Load packages
library(bit64)
library(data.table)
# Create data table
tmp = data.table(x = as.integer64(c(1, 2, NA)), id = 1)
# Grouped min does not work
tmp[, min(x, na.rm = T), by = id]
# Grouped max does work
tmp[, max(x, na.rm = T), by = id]

Output:

> tmp[, min(x, na.rm = T), by = id]
   id   V1
1:  1 <NA>
> # Grouped max does work
> tmp[, max(x, na.rm = T), by = id]
   id V1
1:  1  2

Output of sessionInfo()

R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.4

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] bit64_0.9-7       bit_1.1-14        data.table_1.12.9

loaded via a namespace (and not attached):
[1] compiler_3.6.3 tools_3.6.3   

Metadata

Metadata

Assignees

No one assigned

    Labels

    GForceissues relating to optimized grouping calculations (GForce)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions