冒着因提出“明显”问题而被修改的极端风险,我如何在 R 中找到两个日期之间的差异(以小时为单位)?
> ISOdate(2004,1,6) - ISOdate(2004,1,1)
Time difference of 5 days
> as.POSIXlt(ISOdate(2004,1,6) - ISOdate(2004,1,1))
Error in as.POSIXlt.default(ISOdate(2004, 1, 6) - ISOdate(2004, 1, 1)) :
do not know how to convert 'ISOdate(2004, 1, 6) - ISOdate(2004, 1, 1)' to class "POSIXlt"
> (ISOdate(2004,1,6) - ISOdate(2004,1,1))$year
Error in (ISOdate(2004, 1, 6) - ISOdate(2004, 1, 1))$year :
$ operator is invalid for atomic vectors
> (ISOdate(2004,1,6) - ISOdate(2004,1,1))$mon
Error in (ISOdate(2004, 1, 6) - ISOdate(2004, 1, 1))$mon :
$ operator is invalid for atomic vectors