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

dev version of tabyl() fails on grouped data_frame #125

Closed
sfirke opened this issue Jun 22, 2017 · 2 comments
Closed

dev version of tabyl() fails on grouped data_frame #125

sfirke opened this issue Jun 22, 2017 · 2 comments

Comments

@sfirke
Copy link
Owner

sfirke commented Jun 22, 2017

it ends up running on the grouping variable, not on the intended variable:

> mtcars %>% group_by(am, cyl) %>% summarise(mean_mpg = mean(mpg)) %>% tabyl(cyl)
Adding missing grouping variables: `am`
  am n percent
1  0 3     0.5
2  1 3     0.5
@sfirke
Copy link
Owner Author

sfirke commented Jun 22, 2017

Look to understand why this happens and perhaps rewrite the code, but if something elegant is not possible then have tabyl() ungroup the input (and print a warning?).

@sfirke
Copy link
Owner Author

sfirke commented Jul 27, 2017

This is due to dplyr::select() not letting you unselect a grouping variable - so the fix is indeed to to ungroup(). Let's not print a warning, it's intuitive enough behavior even if you were expecting something grouped.

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

1 participant