Skip to content

filter(.by = ) leads to incorrect results when NAs are present #474

@markfairbanks

Description

@markfairbanks
library(dtplyr)
library(dplyr)
df <- tibble(x = c(1, 2, NA), y = c("a", "a", "b"))

lazy_dt(df) %>%
  filter(x != 2, .by = y)
#> Source: local data table [2 x 2]
#> Call:   `_DT1`[`_DT1`[, .I[x != 2], by = .(y)]$V1]
#> 
#>       x y    
#>   <dbl> <chr>
#> 1     1 a    
#> 2    NA <NA> 
#> 
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results
df %>%
  filter(x != 2, .by = y)
#> # A tibble: 1 × 2
#>       x y    
#>   <dbl> <chr>
#> 1     1 a

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions