Closed jmbarbone closed 2 years ago
@jmbarbone - All fixed! Thanks for catching this.
library(dplyr, warn.conflicts = FALSE)
library(dtplyr, warn.conflicts = FALSE)
x <- tibble(
x = c(1, 1, 2, 2),
y = c(1, 1, 1, 2)
)
x %>%
lazy_dt() %>%
count(x, y) %>%
mutate(z = mean(n))
#> Source: local data table [3 x 4]
#> Call: `_DT1`[, .(n = .N), keyby = .(x, y)][, `:=`(z = mean(n))]
#>
#> x y n z
#> <dbl> <dbl> <int> <dbl>
#> 1 1 1 2 1.33
#> 2 2 1 1 1.33
#> 3 2 2 1 1.33
#>
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results
x %>%
lazy_dt() %>%
group_by(x, y) %>%
count() %>%
mutate(z = mean(n))
#> Source: local data table [3 x 4]
#> Groups: x, y
#> Call: `_DT2`[, .(n = .N), keyby = .(x, y)][, `:=`(z = mean(n)), by = .(x,
#> y)]
#>
#> x y n z
#> <dbl> <dbl> <int> <dbl>
#> 1 1 1 2 2
#> 2 2 1 1 1
#> 3 2 2 1 1
#>
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results
Only the last group is dropped when using
count()
. I think this could be intally.dtplyr_step()
wheresummarise()
is called.Created on 2022-05-11 by the reprex package (v2.0.1)