R: how to filter a timestamp by hour and minute?

前端 未结 5 761
粉色の甜心
粉色の甜心 2020-12-21 00:47

I am struggling with the following example

time = c(\'2013-01-03 21:59:21.549\', \'2013-01-04 22:00:21.549\', \'2013-01-05 22:01:21.222\', \'2013-01-06 22:06         


        
5条回答
  •  执念已碎
    2020-12-21 00:50

    I guess this solves your problem:

    library(dplyr) 
    
    result <- data %>%  
      mutate(time2 = format(time, format="%H:%M:%S")) %>%
      filter(time2 >= "21:59:00" & time2 < "22:02:00") %>%
      select(-time2)
    

提交回复
热议问题