0

I have two tables:

no  checkin checkout    
1   1/3/2018    1/5/2018    

And:

no  check-in    check-out   new checkout date

1   1/3/2018    1/5/2018    1/4/2018
1   1/3/2018    1/5/2018    1/5/2018

I would like to view this on a daily level.

dailyEsp <- difftime(as.Date(Esp$CheckOut, format = '%m/%d/%Y'), as.Date(Esp$CheckIn, format = '%m/%d/%Y'), units = "days")

for (i in 1:dailyEsp){
  newcheckout = as.Date(Esp$CheckIn, format = '%m/%d/%Y') + i - 1
  merge(Esp[nrow(Esp) + dailyEsp,], newcheckout-1) 
}                     

I cannot think of the logic on how to merge existing dataset to the new checkout date.

GhostCat
  • 137,827
  • 25
  • 176
  • 248
xd10
  • 1
  • 2
    I can't quite follow what you are doing here. Is one of the above tables supposed to be `Esp`? And what's the other? It's easier to help if the code and data you provide is in a [reproducible format](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). What exactly is the desired output here? – MrFlick Oct 02 '18 at 19:11
  • Thanks for your input. Esp is a dataset that contains the check-in and check-out date.dailyEsp is to calculate the difference between check-in and check-out date. For the original dataset, I only have check-in and check-out date. I want to spread out to daily level. I want to create a data frame by adding a column called new checkout date. For the example that I provided, instead of only having 1/3-1/5 as one row, I want to create two rows that is 1/3-1/4, 1/4-1/5. My question is how to split up this dataset. Thank you!! – xd10 Oct 02 '18 at 19:22
  • Do you have a lot of groups that you need to do this with? – Calum You Oct 02 '18 at 23:49
  • Welcome to Stack Overflow! Other users marked your question for low quality and need for improvement. I re-worded/formatted your input to make it easier to read/understand. Please review my changes to ensure they reflect your intentions. Feel free to drop me a comment in case you have further questions or feedback for me. – GhostCat Oct 04 '18 at 11:49
  • Having said that: never put more information into comments. Always edit and enhance your question instead! – GhostCat Oct 04 '18 at 11:50

0 Answers0