Skip to content

group_by(.dots) handling - breaking change? #4734

Closed
@jangorecki

Description

@jangorecki

Code that used to work in current CRAN release 0.8.3, does not work anymore in recent devel.
Clean R environment, just installed cran remotes and github dplyr, as of 30m ago.
There seems to be a breaking change in the way how .dots argument is processed(?). I haven't found any references in NEWS file regarding this.

suppressMessages(library(dplyr))
data.frame(a=1:2, b=2:3) %>% group_by(.dots = c("a","b")) %>% summarize(count = n())
#Error: The quosure environment should be explicitly supplied as `env`
#Run `rlang::last_error()` to see where the error occurred.
rlang::last_error()
#<error/rlang_error>
#The quosure environment should be explicitly supplied as `env`
#Backtrace:
#  1. base::data.frame(a = 1:2, b = 2:3)
#  9. dplyr::group_by(., .dots = c("a", "b"))
# 10. dplyr::group_by_prepare(.data, ..., .add = .add)
# 11. dplyr:::compat_lazy_dots(.dots)
# 12. dplyr:::compat_lazy(dots[[i]], env, warn)
# 13. rlang::parse_quo(lazy[[1]], env)
#Run `rlang::last_trace()` to see the full context.
rlang::last_trace()
#<error/rlang_error>
#The quosure environment should be explicitly supplied as `env`
#Backtrace:
#
#  1. └─`%>%`(...)
#  2.   ├─base::withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
#  3.   └─base::eval(quote(`_fseq`(`_lhs`)), env, env)
#  4.     └─base::eval(quote(`_fseq`(`_lhs`)), env, env)
#  5.       └─`_fseq`(`_lhs`)
#  6.         └─magrittr::freduce(value, `_function_list`)
#  7.           └─function_list[[i]](value)
#  8.             ├─dplyr::group_by(., .dots = c("a", "b"))
#  9.             └─dplyr:::group_by.data.frame(., .dots = c("a", "b"))
# 10.               └─dplyr::group_by_prepare(.data, ..., .add = .add)
# 11.                 └─dplyr:::compat_lazy_dots(.dots)
# 12.                   └─dplyr:::compat_lazy(dots[[i]], env, warn)
# 13.                     └─rlang::parse_quo(lazy[[1]], env)

Activity

changed the title [-]group_by(.dots) handling breaking change?[/-] [+]group_by(.dots) handling - breaking change?[/+] on Jan 11, 2020
hadley

hadley commented on Jan 11, 2020

@hadley
Member

Thanks for the bug report — I've fixed the bug and I'm about to make it clear that this argument is deprecated. I'll do a soft deprecation which means it shouldn't affect user group, but it will encourage downstream packages (like dbplyr!) to not use it; we'll move to a stronger deprecation at some point in the future.

added a commit that references this issue on Jan 11, 2020
tylerlittlefield

tylerlittlefield commented on Mar 18, 2021

@tylerlittlefield

I'm updating a package to remove usage of .dots the news file suggests !!!. I was just curious if that is still the case or if across might be preferred. I'm trying to decide which of the two examples I should use:

library(dplyr)
library(rlang)

# leaning towards this one
mtcars %>% 
  group_by(across(c("mpg", "cyl")))

mtcars %>% 
  group_by(!!!syms(c("mpg", "cyl")))
hadley

hadley commented on Mar 18, 2021

@hadley
Member

@tyluRp either is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @hadley@jangorecki@tylerlittlefield

        Issue actions

          group_by(.dots) handling - breaking change? · Issue #4734 · tidyverse/dplyr