I have trouble with an error in zoo, using the lag.zoo function
Error in rbind.zoo(...) : indexes overlap Warning: In zoo(rval[i], index(x)[i]) : some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique
t1<-c("21.04.2019 20:00:00","21.04.2019 20:01:00","21.04.2019 20:02:00","21.04.2019 20:03:00","21.04.2019 20:04:00","21.04.2019 20:05:00","21.04.2019 20:06:00","21.04.2019 20:07:00","21.04.2019 20:08:00","21.04.2019 20:09:00","21.04.2019 20:10:00","21.04.2019 20:11:00")
v1<-c(15,15,15,14,15,14,15,14,15,15,15,14)
z1<-zoo(v1, as.POSIXct(strptime((t1), "%d.%m.%Y %H:%M:%S")))
head(lag(z1[,1], 2))
Using k=1 gives back the original time without lag (and no error and warning)
head(stats::lag(z1[,1], 2)), there are some 'genious' packages out there that mask thelagfunction. - jay.sf