当zoo
对象为空时,rollapply
会抛出错误而不是只返回任何内容:
require(zoo)
z = na.omit(zoo(cbind(NA,NA), as.Date("2012-01-01")))
rollapply(z, width=10, FUN=mean, by=1, by.column=F, partial=5, align="right")
Error in seq.default(start.at, NROW(data), by = by) :
wrong sign in 'by' argument
错误与否?
sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: x86_64-unknown-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=C LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] zoo_1.7-9
loaded via a namespace (and not attached):
[1] grid_2.15.2 lattice_0.17-26