I'm trying to calculate how long one person stays in a homeless shelter using R. The homeless shelter has two different types of check-ins, one for overnight and another for a long-term. I would like to shape the data to get an EntryDate and ExitDate for every stay which does not have at least a one day break.
Here are what the data currently look like:
PersonalID EntryDate ExitDate
1 2016-12-01 2016-12-02
1 2016-12-03 2016-12-04
1 2016-12-16 2016-12-17
1 2016-12-17 2016-12-18
1 2016-12-18 2016-12-19
2 2016-10-01 2016-10-20
2 2016-10-21 2016-10-22
3 2016-09-01 2016-09-02
3 2016-09-20 2016-09-21
Ultimately, I'm trying to get the above date to represent continuous ranges to calculate total length of stay by participant.
For example, the above data would become:
PersonalID EntryDate ExitDate
1 2016-12-01 2016-12-04
1 2016-12-16 2016-12-19
2 2016-10-01 2016-10-22
3 2016-09-01 2016-09-02
3 2016-09-20 2016-09-21