[R] Find tibble row with maximum recorded value

Rich Shepard r@hep@rd @end|ng |rom @pp|-eco@y@@com
Sat Dec 4 00:06:28 CET 2021

On Fri, 3 Dec 2021, Rui Barradas wrote:

>> which.max(pdx_disc$cfs)
>> [1] 8054

> This is the *index* for which cfs is the first maximum, not the maximum
> value itself.


Mea culpa! I completely forgot this.

> Therefore, you probably want any of
> filter(pdx_disc, cfs == cfs[8054])
> filter(pdx_disc, cfs == cfs[which.max(cfs)])
> filter(pdx_disc, cfs == max(cfs))    # I find this one better, simpler

> Hope this helps,

Yes, it does.

Thank you very much,


More information about the R-help mailing list