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

[BUG?] filter() throws error after group_by() %>% do() #1134

Closed
antoine-lizee opened this issue May 13, 2015 · 4 comments
Closed

[BUG?] filter() throws error after group_by() %>% do() #1134

antoine-lizee opened this issue May 13, 2015 · 4 comments
Assignees
Milestone

Comments

@antoine-lizee
Copy link

It took me a while to create a reproducible example - I hope this is not double posting (see #278 - similar problem supposed to be solved?). It seems that there is a problem with the lazy evaluation:

# Example filtering that works
res <- diamonds %>% filter(carat >= min(diamonds$carat))
# Let's throw in a random grouped operation:
interm <- diamonds %>% group_by(clarity) %>% do(data.frame(.))
# This breaks:
interm %>% filter(carat >= min(diamonds$carat))
# This doesn't:
m <- min(diamonds$carat)
interm %>% filter(carat >= m)
@realAkhmed
Copy link

I can confirm that I experience the same issue. Adding ungroup() before filter() solves the issue

interm %>% ungroup() %>% filter(carat >= min(diamonds$carat))

@hadley
Copy link
Member

hadley commented May 19, 2015

Minimal reprex:

library(ggplot2)
library(dplyr)

interm <- diamonds %>% group_by(clarity) %>% do(data.frame(.))
interm %>% filter(carat >= min(diamonds$carat))
interm %>% ungroup() %>% filter(carat >= min(diamonds$carat))

probably something to do with rowwise

@hadley hadley added this to the 0.5 milestone May 19, 2015
@romainfrancois romainfrancois self-assigned this Jul 15, 2015
@romainfrancois
Copy link
Member

This was a problem in hybrid evaluation.

@antoine-lizee
Copy link
Author

Thanks!

@lock lock bot locked as resolved and limited conversation to collaborators Jun 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants