【发布时间】:2023-03-12 20:19:01
【问题描述】:
考虑以下:
library(lubridate)
period1 = weeks(2)
as.numeric(period1, "weeks")
> 2 # as expected
现在我正在尝试用几个月做类似的事情:
period2= months(6)
as.numeric(period2, "months")
as.numeric(period2, "weeks")
> 26.08929 # OK
as.numeric(period2,"months")
> 0.04166667 # Not OK?
这是lubridate 中的错误吗?还是我做错了什么/错过了什么?
注意:我已经看到(旧)评论Have lubridate subtraction return only a numeric value,所以我想我也可以使用解决方法来使用difftime,但我想坚持使用润滑。
【问题讨论】:
-
假设这不是我们想要的行为,我怀疑
seconds_to_unit或period_to_seconds可能值得探索。