Skip to content

top_n(10, -n) vs. btm_n(10, n) #1352

@npjc

Description

@npjc

I use count(group) %>% top_n(10, -n) type-of-thing lots... Future me would prefer if I could use count(group) %>% btm_n(10, n) instead as it is more easily understood at a glance.

From ?top_n():

# Find 10 players with most games
require("Lahman")
tbl_df(Batting) %>%
  group_by(playerID) %>%
  tally(G) %>%
  top_n(10)

I wish for:

# to find the 10 players with least games
# currently
... %>% top_n(10, -n)
# wishful behaviour
... %>% btm_n(10, n)

Or perhaps it is easier to just document examples of how you'd get the bottom n of something under top_n()

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions