Tl;dr: The trouble with ntile seems to be that, when the author of the post imagined what it did based solely on its name and she imagined wrong, she ran with her imaginary version way too long before checking the docs, which was very clear about its behavior:
> Unlike other ranking functions, ntile() ignores ties: it will create evenly sized buckets even if the same value of x ends up in different buckets.
I’m pretty sure NTILE is just a generally cursed function. SQL NTILE also requires everything to be loaded in memory because of the odd rule that larger buckets precede smaller buckets, so it’s unusable on anything decently sized.
Not being able to specify how ties are handled (and choosing, as far as I can tell, a fairly useless definition) fits the bill.
Actually, you can completely specify how ties are handled—and should, in any study designed to be repeatable. The docs for dplyr::ntile tell you that:
> To rank by multiple columns at once, supply a data frame.
So, repeatable specified tiebreaking is as easy as adding a tiebreaker column to the dataset, using whatever strategy makes sense for your study. For example, if we wanted random tiebreaking using R's built-in `runif`:
3 comments
[ 0.26 ms ] story [ 27.4 ms ] thread> Unlike other ranking functions, ntile() ignores ties: it will create evenly sized buckets even if the same value of x ends up in different buckets.
Not being able to specify how ties are handled (and choosing, as far as I can tell, a fairly useless definition) fits the bill.
> To rank by multiple columns at once, supply a data frame.
So, repeatable specified tiebreaking is as easy as adding a tiebreaker column to the dataset, using whatever strategy makes sense for your study. For example, if we wanted random tiebreaking using R's built-in `runif`:
Almost 100% of the original author's problems could have been solved by just reading the docs.