R version 4.5.0 RC (2025-04-04 r88118 ucrt) -- "How About a Twenty-Six" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ## packages > library("zoo") Attaching package: 'zoo' The following objects are masked from 'package:base': as.Date, as.Date.numeric > library("timeDate") > > ## aggregate() with "timeDate" index > z <- zoo(1:3, timeDate(c("2011-09-19 12:00", "2011-09-19 12:00", "2011-09-19 13:00"))) Warning message: In zoo(1:3, timeDate(c("2011-09-19 12:00", "2011-09-19 12:00", "2011-09-19 13:00"))) : some methods for "zoo" objects do not work if the index entries in 'order.by' are not unique > aggregate(z, identity, mean) 2011-09-19 12:00:00 2011-09-19 13:00:00 1.5 3.0 > > ## assignment and preservation of column names in merge() > x <- zoo(cbind(a = 3:4, b = 5:6)) > y <- zoo(1:2) > merge(x, zoo(, time(x))) a b 1 3 5 2 4 6 > merge(y, x) y a b 1 1 3 5 2 2 4 6 > > ## [<-.zoo with logical row index > z <- zoo(cbind(1:5, 11:15), 101:105) > z[index(z) == 103, 1] <- 0 > > ## rollapply(..., mean, partial = TRUE) > z <- zoo(11:15) > identical(rollapply(z, 3, mean, partial = TRUE), + rollapply(z, 3, (mean), partial = TRUE)) [1] TRUE > > ## rollmedian(..., k = 1) > z <- zoo(sin(0:20)) > identical(z, rollmedian(z, 1)) [1] TRUE > identical(coredata(rollmedian(z, 1)), as.vector(runmed(coredata(z), 1))) [1] TRUE > > ## na.fill with just NAs (directly and implicitly through rollapply) > na.fill(c(NA, NA), fill = NA) [1] NA NA > rollapply(1:2, 3, sum, fill = NA) [1] NA NA > > proc.time() user system elapsed 0.29 0.03 0.31