-
Notifications
You must be signed in to change notification settings - Fork 167
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
Add support for ntile() with window_order() #1235
Comments
As a follow-up to the above, in other places This works fine: earthquakes %>%
filter(!is.na(mag), place == 'Northern California') %>%
group_by(place) %>%
window_order(mag) %>%
mutate(percentile = percent_rank()) But this produces an error: earthquakes %>%
filter(!is.na(mag), place == 'Northern California') %>%
group_by(place) %>%
mutate(percentile = percent_rank(order_by = "mag")) Error message:
|
The error message in the follow-up makes sense. |
That makes sense (I've never used the BTW, I discovered this in "translating" a book on SQL to So far everything has worked, while |
I just glimpsed over your book but it already looks like some nice work! I'm happy to help with questions or bugs you encounter when working with dbplyr 😄 |
This is definitely a weird one. Note I am simply translating someone else's (excellent) book code from SQL to |
This request is similar to #169. It seems that
dbplyr
will translatentile
when given a value fororder_by
, but not withwindow_order()
. This seems to be a documentation issue, as many window functions are translated nicely withwindow_order()
.Ideally one could also do this:
But only this form seems to work:
Note that there is a slight difference between
dplyr::ntile()
andntile()
indbplyr
.The former is
ntile(x = row_number(), n)
, whereas the latter requires theorder_by
argument.The
dplyr
version of the above is something like:(Note that #627 was closed.)
This is a feature request and seems clear enough, so I have not included a reprex, but could do so if this helped.
As an aside, the "ideal" code above produces the error message below. Perhaps a clearer error message would be an alternative.
The text was updated successfully, but these errors were encountered: