Reputation: 53
I'm trying to create a visualization that shows for some predecessor/successor operations, how many employees are clocked in through a 24 hour clock.
I created a vector of instances two hours a part from each other. I converted a table of labor records (clock-in and clock-out) to a data.frame of intervals. When I use the %within% function I only get the T/F back for the first instance of my vector.
graph.instants <- seq( ymd("2014-05-12"), by= "2 hours", len= 120) #Make vector of instants in 2 hour intervals
ln205intervals <- data.frame(ints = interval(Frame206$LaborOn, Frame206$LaborOff)) #Make intervals with LN205 data
graph.instants %within% ln205intervals$ints
Is there a way to check a vector of instants against a vector of intervals?
Here is a picture of my problem:
Upvotes: 4
Views: 181
Reputation: 1271
for the archive as an alternative: dplyr defines a between
library(lubridate)
library(dplyr)
dat <- data.frame(time = seq( ymd("2015-01-01"), by= "2 hours", len= 1000))
dat %>% filter(between(time, ymd("2015-01-10"), ymd("2015-01-11")))
Upvotes: 1