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

Add a na.rm argument to first()/last() #4239

Open
nbenn opened this issue Feb 12, 2020 · 1 comment · May be fixed by #5168
Open

Add a na.rm argument to first()/last() #4239

nbenn opened this issue Feb 12, 2020 · 1 comment · May be fixed by #5168

Comments

@nbenn
Copy link
Member

nbenn commented Feb 12, 2020

Personally, I'd find it useful if gfirst()/glast() would accept a na.rm argument. This would then return the first/last non missing element of a vector (within each group).

For consistency I guess also first()/last() should then accept a na.rm argument. Although I'm not sure what this would mean if a non-atomic object (i.e. a data.frame) was passed. Maybe the flag should only be honored if is.atomic(x) && nargs() == 1L?

@ben-schwen
Copy link
Member

What should happen in cases, where a group contains no non NA element?

Whats happens in other gfunctions for those groups?

  • gsum returns 0
  • gmedian, gvar and gsd return NA
  • gmean returns NaN
  • gprod returns 1
  • gmax/gmin return Inf

@ben-schwen ben-schwen linked a pull request Sep 18, 2021 that will close this issue
1 task
@mattdowle mattdowle added this to the 1.14.3 milestone Dec 13, 2021
@jangorecki jangorecki modified the milestones: 1.14.3, 1.14.5 Jul 19, 2022
@jangorecki jangorecki modified the milestones: 1.14.11, 1.15.1 Oct 29, 2023
@MichaelChirico MichaelChirico modified the milestones: 1.16.0, 1.17.0 Jul 11, 2024
@MichaelChirico MichaelChirico modified the milestones: 1.17.0, 1.16.0 Jul 30, 2024
@MichaelChirico MichaelChirico modified the milestones: 1.17.0, 1.18.0 Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants