I have a list of people and their working start and end time during the day. I want to build a curve showing the total number of people working any minute of the day. I could add only 1440 additional conditional logical variables for every minute of the day and summarize them, but this seems very inelegant. I am wondering if there is a better way to do this (integrals?).
Here is the code for generating df with my sample data:
sample_wt <- function() { require(lubridate) set.seed(10) worktime <- data.frame( ID = c(1:100), start = now()+abs(rnorm(100,4800,2400)) ) worktime$end <- worktime$start + abs(rnorm(100,20000,10000)) worktime$length <- difftime(worktime$end, worktime$start, units="mins") worktime }
To create a sample data, you can do something like:
DF <- sample_wt()
datetime r plot
Timm S.
source share