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

@antoine-lizee antoine-lizee commented May 13, 2015

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

@realAkhmed realAkhmed commented May 15, 2015

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 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

@romainfrancois romainfrancois commented Jul 15, 2015

This was a problem in hybrid evaluation.

@antoine-lizee
Copy link
Author

@antoine-lizee antoine-lizee commented Jul 15, 2015

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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants