动物园里可能存在的错误 - R [提交前检查]

时间:2013-03-28 21:10:33

标签: r time-series xts zoo

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

0 个答案:

没有答案