【发布时间】:2019-12-28 00:16:27
【问题描述】:
我正在尝试按小时/时间拆分,而日期不会影响结果,我正在使用按日期和时间索引的 xts 对象
当我使用按小时拆分时,我得到了结果,但在日期内,我希望忽略日期,只按时间得到,试图去掉日期并返回 posixct,但没有帮助,我也尝试将 period.apply 与端点一起使用,但结果相同。
lapply(split(temp[,"GROSS"] , f = "hour"), FUN = cumsum)
[[1]]
GROSS
2018-10-12 09:46:38 "11"
[[2]]
GROSS
2018-10-12 10:04:08 "-4"
2018-10-12 10:23:58 "5.2"
2018-10-12 10:24:08 "-1.1"
[[3]]
GROSS
2018-10-15 09:35:46 "20.7"
[[4]]
GROSS
2018-10-17 09:30:56 "-7.2"
[[5]]
GROSS
2018-10-17 10:44:48 "13.5"
我希望得到没有日期的按小时累积的结果。
【问题讨论】:
-
请通过
dput(head(temp[,"GROSS"]))提供您的数据示例 -
> dput(head(temp[,"GROSS"])) 结构(c(“11.00”,“-4.00”,“9.20”,“-6.30”,“20.70”,“- 7.20"), class= c("xts", "zoo"), .indexCLASS = c("POSIXlt", "POSIXt"), tclass= c("POSIXlt", "POSIXt"), .indexTZ = "UTC" , tzone = "UTC", index = 结构(c(1539337598, 1539338648, 1539339838, 1539339848, 1539596146, 1539768656), tzone = "UTC", tclass= c("POSIXlt", "cPOSIXt")), .Dim (6L, 1L), .Dimnames = list(NULL, "GROSS")) @shs