tidyverse / dtplyr

Data table backend for dplyr
https://dtplyr.tidyverse.org
Other
670 stars 57 forks source link

Error when `where()` is used in `across()` #363

Closed markfairbanks closed 2 years ago

markfairbanks commented 2 years ago

Closes #271

The biggest thing this prevents is the "silent failure" cases.

library(dtplyr)
library(dplyr, warn.conflicts = FALSE)

df <- tibble(x = 1:3, y = c("a", "b", "c"), z = c("a", "a", "b"))

lazy_dt(df) %>%
  group_by(z) %>%
  summarize(across(!where(is.numeric), first))
#> Source: local data table [2 x 3]
#> Call:   `_DT1`[, .(x = first(x), y = first(y)), keyby = .(z)]
#> 
#>   z         x y    
#>   <chr> <int> <chr>
#> 1 a         1 a    
#> 2 b         3 c    
#> 
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results

Note: This can be updated later if https://github.com/r-lib/tidyselect/issues/226 is implemented.

eutwt commented 2 years ago

Should we implement a temporary eval_select wrapper in dtplyr that disallows predicates until that happens? That way this would be fixed for other cases too. In dplyr you can use where in select, relocate, rename_with, mutate's .before and .after, and it looks like all of those are silent failures in dtplyr.

markfairbanks commented 2 years ago

Yeah I like that option better - I'll close this PR and we can do that in a different one.

markfairbanks commented 2 years ago

FYI @eutwt I opened an issue for adding the helper