'How to fix an incorrectly calculated schedule in R
Sample of mydata
incorrect_shed=structure(list(date = c(4L, 4L, 7L, 7L), start_hour = c(9L, 9L,
11L, 10L), end_hour = c(19L, 18L, 20L, 20L)), class = "data.frame", row.names = c(NA,
-4L))
second dataset is worktime of shop.For example this shop works from 9-20
timework=structure(list(opening_time = c("09:00:00.0000000", "09:00:00.0000000",
"09:00:00.0000000", "09:00:00.0000000", "09:00:00.0000000", "09:00:00.0000000",
"09:00:00.0000000"), closing_time = c("20:00:00.0000000", "20:00:00.0000000",
"20:00:00.0000000", "20:00:00.0000000", "20:00:00.0000000", "20:00:00.0000000",
"20:00:00.0000000"), closing_time.1 = c("20:00:00.0000000", "",
"", "", "", "", "")), class = "data.frame", row.names = c(NA,
-7L))
As we can see date=4 from incorrect_shed. This mean that in this day work 2 persons one from 9-19,and second from c 9-18. It is mean then both person leave shop early then 20 o'clock. It's wrong . It is necessary to rearrange the persons in such a way that one always works from the very beginning of the opening of the store, and the second does not leave before closing.
Also here we see that second person works 9 hour, and the first person work 10 hours.
This means that person who works 9 hours. must start work from the very beginning of the opening(9:00), and person who works 10 hours must work 10 hours and leave at the closing hour, i.e. he should start working at 10 o'clock and finish at 20 o'clock, in this way, both persons will not come and leave before the store closes and each will work out the schedule set for him (9 or 10 hours).
How to implement such logic if that case occured(sometimes it can be)?
Also can be situation when both person became work later than shop opened. date=7 . Person who works 9 hour start work from 11-20, and person who works 10 hours came from 10-20
so one must work from 9-19(10 hours) and second from 11-20(9 hour).
In other words, the main task is, if it so happened that on what date there are violations of closing and opening, people left before the store closed or begin later than the opening, then rearrange their clock so that they do not leave earlier or come later than the store opens. Opening and closing time always in timework
How to how to satisfy such a logical condition?
Please help me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
