我有一个名为 example.csv 的文件,其中包含该数据:
day,number,price
2010-01-01 00:01:00,1,0.4
2010-01-01 00:02:00,2,1.2
2010-01-01 00:03:00,3,2.5
2010-01-01 00:04:00,4,9.1
2010-01-01 00:05:00,5,3.4
2010-01-01 00:06:00,6,6.9
2010-01-01 00:07:00,7,8.9
2010-01-01 00:08:00,8,9.1
2010-01-01 00:09:00,9,4.2
2010-01-01 00:10:00,10,11.2
2010-01-01 00:11:00,11,53.12
2010-01-01 00:12:00,12,45.21
2010-01-01 00:12:00,13,1.1
2010-01-01 00:13:00,14,3.43
2010-01-01 00:14:00,15,21.42
加载文件内容:
example = read.csv(file="path/example.csv", sep=",")
加载
DD <- structure(list(day = structure(c(example$day), class = c("POSIXct", "POSIXt"), tzone = ""),
number = c(example$number), price = c(example$price)), .Names = c("day", "number", "price"), row.names = c(NA,
-15L), class = "data.frame")
后:
ddx <- xts(DD[,c('number','price')], order.by = DD[,'day'])
并且: period.apply(ddx, endpoints(ddx, on = 'minutes',k=3), sum)
在最后一个 period.apply 之后,它会返回:
[,1]
1970-01-01 02:00:14 301.18
为什么它还给1970