Find most recent observation - R

后端 未结 1 1240
一个人的身影
一个人的身影 2021-01-24 10:08

I have two sets of (sorted) POSIXct time series like this:

set.seed(123)
ll = sort(strptime(\"16/07/2015\", format=\"%d/%m/%Y\") + 10*3600 + 1:3600 + round(rnorm         


        
1条回答
  •  囚心锁ツ
    2021-01-24 10:14

    Just use findInterval:

    array(findInterval(tt1,ll),dim(tt1))
    #head(array(findInterval(tt1,ll),dim(tt1))[,1:4])     
    #     [,1] [,2] [,3] [,4]
    #[1,]  729  729  731  732
    #[2,]  740  741  742  743
    #[3,]  748  749  751  752
    #[4,]  759  760  760  762
    #[5,]  770  772  773  774
    #[6,]  780  781  783  785
    

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