2017-01-31 33 views

回答

3

一個實現你需要什麼樣的方式是使用rollapplyzoo包。

library(zoo) 
rollapply(x, width = 7, by = 4, mean) 
#[1] 622.1429 682.8571 540.7143 

DATA

x <-c(267, 497, 836, 498, 923, 836, 498, 923, 267, 497, 836, 498, 923, 267, 497) 
+1

完美的感謝....配發節省手工編碼的。 – PaulBeales