alignment and offsets in rollapply
问题 I am trying to calculate some statistics for a moving window and am using rollapply in the zoo package. My question is how do I get rollapply to apply that function to the previous n observations instead of the current observation and the previous n-1 observations as align right seems to do. require(zoo) z <- data.frame(x1=11:111, x2=111:211, x3=as.Date(31:131))#generate data output<-data.frame(dates=z$x3, rollapply(z[,1:2],by.column=TRUE, 5, max, fill=NA, align='right')) I have a hunch this