indicateing to which interval a date belongs

后端 未结 1 1104
太阳男子
太阳男子 2021-01-29 17:08
4/1/2014 0:11   40.769  -73.9549    B02512|
4/1/2014 0:17   40.7267 -74.0345    B02512|
4/1/2014 0:21   40.7316 -73.9873    B02512|
4/1/2014 0:28   40.7588 -73.9776    B         


        
1条回答
  •  有刺的猬
    2021-01-29 17:17

    Using lubridate's floor_date function:

    df$interv<-lubridate::floor_date(df$time, unit="15 minutes")
    

    (This assumes that your time column is some recognized date-time format (e.g., POSIXt), which it doesn't seem to be from your sample's formatting.)

    For example:

    a<-Sys.time()
    a
    [1] "2019-01-08 09:22:22 EST"
    floor_date(a,unit="15 minutes")
    [1] "2019-01-08 09:15:00 EST"
    

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