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

前端 未结 2 685
独厮守ぢ
独厮守ぢ 2021-01-01 01:45

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

相关标签:
2条回答
  • 2021-01-01 02:39

    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)
    
    0 讨论(0)
  • 2021-01-01 02:50

    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.

    0 讨论(0)
提交回复
热议问题