R/zoo: index entries in ‘order.by’ are not unique

我是研究僧i 提交于 2019-11-30 10:02:24

anyDuplicated(har10) tells you if any complete rows are duplicated. zoo is warning about the index, so you should run anyDuplicated(har10$HAR.TS). sum(duplicated(har10$HAR.TS)) will show there are almost 9,000 duplicate datetimes. The first duplicate is around row 311811, where 10/08/19 13:10 appears twice.

Amos Folarin

And to handle duplicated indices (see ?zoo and ?aggregate.zoo)

## zoo series with duplicated indexes
z3 <- zoo(1:8, c(1, 2, 2, 2, 3, 4, 5, 5))
plot(z3)

## remove duplicated indexes by averaging
lines(aggregate(z3, index, mean), col = 2, type = "o")

## or by using the last observation
lines(aggregate(z3, index, tail, 1), col = 4)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!