indicateing to which interval a date belongs

我们两清 提交于 2019-12-02 15:17:07

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"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!