nathaneastwood / poorman

A poor man's dependency free grammar of data manipulation
https://nathaneastwood.github.io/poorman/
Other
338 stars 15 forks source link

Ensure summarise() maintains the .drop attribute #84

Closed nathaneastwood closed 3 years ago

nathaneastwood commented 3 years ago

Example of failing tests:

df <- data.frame(
  f1 = factor("a", levels = c("a", "b", "c")),
  f2 = factor("d", levels = c("d", "e", "f", "g")),
  x = 42
)

res <- df %>%
  group_by(f1, f2, .drop = TRUE)
expect_equal(n_groups(res), 1L, info = "summarise maintains the .drop attribute")

res2 <- summarise(res, x = sum(x))
expect_equal(n_groups(res2), 1L, info = "summarise maintains the .drop attribute")
expect_true(group_by_drop_default(res2), info = "summarise maintains the .drop attribute")