如何計算例如5分鐘的xts對象的時間加權平均值: 我知道weighted.mean(),但不知道如何處理日期和時間。 感謝xts或動物園中的時間加權平均值
library(xts)
structure(c(28.2, 28.2, 28.2, 28.2, 28.1, 28.1, 28.1, 28.1, 28.1,
28.2, 28.3, 28.2, 28.2, 28.1, 28.1, 28.1, 28.1, 28.1, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 27.9, 27.9, 27.9, 27.9,
27.9, 27.9, 27.8, 27.8, 27.8, 27.8, 27.8, 27.8, 27.8, 27.8, 27.8,
27.8, 27.8, 27.8, 27.8, 27.8, 27.8, 27.8, 27.8, 27.8, 27.8, 27.8,
27.7, 27.7, 27.7, 27.8), class = c("xts", "zoo"), .indexCLASS = c("POSIXct",
"POSIXt"), tclass = c("POSIXct", "POSIXt"), .indexTZ = "", tzone = "", index = structure(c(1356998400,
1356998460, 1356998520, 1356998580, 1356998640, 1356998700, 1356998760,
1356998880, 1356998940, 1356999000, 1356999060, 1356999120, 1356999180,
1356999240, 1356999300, 1356999360, 1356999420, 1356999480, 1356999540,
1356999600, 1356999660, 1356999720, 1356999780, 1356999840, 1356999900,
1356999960, 1357000020, 1357000080, 1357000140, 1357000200, 1357000260,
1357000320, 1357000380, 1357000440, 1357000500, 1357000560, 1357000620,
1357000680, 1357000740, 1357000800, 1357000860, 1357000920, 1357000980,
1357001040, 1357001100, 1357001160, 1357001220, 1357001280, 1357001340,
1357001400, 1357001460, 1357001520, 1357001580, 1357001640, 1357001700,
1357001760, 1357001820, 1357001880, 1357001940, 1357002000), tzone = "", tclass = c("POSIXct",
"POSIXt")), .Dim = c(60L, 1L))
這並不比你刪除的問題好多少。你提供了一些樣本數據很好,但是輸出應該是什麼?你的數據是有規律的,所以常規平均值和時間加權平均值是相同的。目前還不清楚你在問什麼。 –
對不起,我錯過了刪除之間的一個項目,現在它不再經常 - 這只是一個例子,有時5個值在1小時內丟失。 –