I have a .csv file containing 4 columns of data against a column of dates/times at one-minute intervals. Some timestamps are missing, so I\'m trying to generate the missing
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)
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.