tsibble icon indicating copy to clipboard operation
tsibble copied to clipboard

max does not return maximum yearmonth from passed arguments

Open Fuco1 opened this issue 3 years ago • 2 comments

Taking a max of two yearmonths, the smaller (earlier) is returned.

> max(yearmonth('2017-01-01'), yearmonth('2018-04-01'))
<yearmonth[1]>
[1] "2017 Jan"

However, taking a max of two date objects, the bigger (later) is correctly returned.

> max(as.Date('2017-01-01'), as.Date('2018-04-01'))
[1] "2018-04-01"
> 

Fuco1 avatar May 07 '21 12:05 Fuco1

This is an inherited from the {vctrs} package, the relevant issue for this is here: https://github.com/r-lib/vctrs/issues/1372

Passed via

library(tsibble)
max(yearmonth('2017-01-01'), yearmonth('2018-04-01'))
#> <yearmonth[1]>
#> [1] "2017 Jan"

Passed via ..1 (x)

max(c(yearmonth('2017-01-01'), yearmonth('2018-04-01')))
#> <yearmonth[1]>
#> [1] "2018 Apr"

Created on 2021-05-26 by the reprex package (v2.0.0)

mitchelloharawild avatar May 26 '21 03:05 mitchelloharawild

I see. I suppose we can close this issue then, unless you want to use it as a soft pressure device for the upstream :D Thanks for the heads up!

Fuco1 avatar May 28 '21 19:05 Fuco1