You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When doing a count on a grouped data.table with dtplyr, only the variable you are counting by is passed to keyby=, but not the current grouping variables (as is the "regular" behaviour in dplyr).
suppressPackageStartupMessages(library(dplyr))
flight_dt<-nycflights13::flights %>%
dtplyr::lazy_dt()
# This is how it works on a data.tableflight_dt %>%
group_by(year, month) %>%
count(tailnum)
#> Source: local data table [?? x 2]#> Call: `_DT1`[, .(n = .N), keyby = .(tailnum)]#> #> tailnum n#> <chr> <int>#> 1 <NA> 2512#> 2 D942DN 4#> 3 N0EGMQ 371#> 4 N10156 153#> 5 N102UW 48#> 6 N103US 46#> #> # Use as.data.table()/as.data.frame()/as_tibble() to access results# This works and gives the expected output of the previous codeflight_dt %>%
group_by(year, month, tailnum) %>%
count()
#> Source: local data table [?? x 4]#> Call: `_DT1`[, .(n = .N), keyby = .(year, month, tailnum)]#> #> year month tailnum n#> <int> <int> <chr> <int>#> 1 2013 1 <NA> 155#> 2 2013 1 N0EGMQ 41#> 3 2013 1 N10156 28#> 4 2013 1 N102UW 1#> 5 2013 1 N103US 4#> 6 2013 1 N104UW 2#> #> # Use as.data.table()/as.data.frame()/as_tibble() to access results
When doing a count on a grouped data.table with dtplyr, only the variable you are counting by is passed to
keyby=
, but not the current grouping variables (as is the "regular" behaviour in dplyr).Created on 2019-08-22 by the reprex package (v0.2.0).
p.s. this package is amazing 😍
The text was updated successfully, but these errors were encountered: