Closed DavisVaughan closed 1 year ago
Same problem with casting existing Period object to months
(goes through a different code path, but looks like a copy/paste)
library(lubridate)
#>
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#>
#> date, intersect, setdiff, union
x <- years(1:5)
y <- as.period(x, "month")
unclass(y)
#> [1] 0 0 0 0 0
#> attr(,"year")
#> [1] 0
#> attr(,"month")
#> [1] 12 24 36 48 60
#> attr(,"day")
#> [1] 0 0 0 0 0
#> attr(,"hour")
#> [1] 0 0 0 0 0
#> attr(,"minute")
#> [1] 0 0 0 0 0
Created on 2023-03-15 with reprex v2.0.2.9000
Seen here https://github.com/tidyverse/dplyr/issues/6789
A large amount of things rely on the Period internals being recycled to the same length, so I think this is a bug (unlike where POSIXlt allows partially recycled elements, which is just a mess)
Seems relatively easy to fix by going through the
new()
Period constructor, which does recycling andNA
standardization for us.