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
Another idea would be the following. You can create a numeric vector using hour, minute, and second. You can extract them with format()
and convert character to numeric. Then, you subset the data with the two numbers indicating the time range you want (i.e., 215900, 220100).
library(dplyr)
data %>%
mutate(foo = as.numeric(format(time, "%H%M%S"))) %>%
filter(between(foo, 215900, 220100)) %>%
select(-foo)
# time value
#
#1 2013-01-03 21:59:21 1
#2 2013-01-04 22:00:21 2