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

Default for top_n #370

Closed
romainfrancois opened this issue Apr 4, 2014 · 2 comments
Closed

Default for top_n #370

romainfrancois opened this issue Apr 4, 2014 · 2 comments

Comments

@romainfrancois
Copy link
Member

Currently the default behavior of top_n is to use the last variable when none is specified. Just wondering if it would perhaps make more sense to use the indices.

For example:

iris %.% group_by(Species) %.% top_n(2)

will use the last variable Species. Of course, within each group, all values for Species are equal, so this will give us the entire data.

So I'm wondering if iris %.% group_by(Species) %.% top_n(2) should express "the two first rows in each group"

@hadley
Copy link
Member

hadley commented Apr 7, 2014

I think this probably should be the job for another function, since it's not quite the regular defintion of top_n(). I was thinking of building slice() out of integer_filter().

@romainfrancois
Copy link
Member Author

About slice, i'd like to avoid materialising the indices, which should not be too hard if we define the perimeter allowed by the arguments.

@hadley hadley closed this as completed Apr 15, 2014
@lock lock bot locked as resolved and limited conversation to collaborators Jun 10, 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

2 participants