dplyr icon indicating copy to clipboard operation
dplyr copied to clipboard

`first()`, `last()`, and `nth()` should have `na.rm` argument

Open hadley opened this issue 2 years ago • 4 comments

Since they're summary functions

hadley avatar Apr 26 '22 13:04 hadley

Do you want it to be na.rm or na_rm? first() and friends have order_by as an argument already so we'd end up with a mix of snake and dot case.

I think I have a slight preference for na_rm to avoid the mixed case, and because we generally use _. I personally prefer this over being similar to base R usage of na.rm

DavisVaughan avatar May 06 '22 18:05 DavisVaughan

Hmmmm, I'm not sure. In most cases I think using snake case would be the obvious choice, but na.rm is just so ubiquitous. But you're probably right that na_rm is the better choice.

hadley avatar May 08 '22 19:05 hadley

Good point on the mixing of cases, I just changed all to na_rm instead in #6257

tnederlof avatar Jun 02 '22 12:06 tnederlof

Randomly stumbled across a case where someone could use this https://stackoverflow.com/questions/73282239/retrieve-first-non-na-value-based-on-another-time-variable

DavisVaughan avatar Aug 08 '22 18:08 DavisVaughan