Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jangorecki opened this issue Jan 11, 2020 · 3 comments
Closed

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

jangorecki opened this issue Jan 11, 2020 · 3 comments

Comments

@jangorecki
Copy link

jangorecki commented Jan 11, 2020

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)
@jangorecki jangorecki changed the title group_by(.dots) handling breaking change? group_by(.dots) handling - breaking change? Jan 11, 2020
@hadley hadley closed this as completed in 8d7ff18 Jan 11, 2020
@hadley
Copy link
Member

hadley commented Jan 11, 2020

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.

hadley added a commit that referenced this issue Jan 11, 2020
@tylerlittlefield
Copy link

tylerlittlefield commented Mar 18, 2021

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
Copy link
Member

hadley commented Mar 18, 2021

@tyluRp either is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants