My problem is easy to explain :
- I have one table with start dates and end dates and n rows ordered by "start date" (see image bellow - Yellow rows are the ones I want to have on one unique row with first start date and last end date)
Table with rows where dates follow
- I would like to regroup dates on one row when start date n+1 == end date n. Here is an exemple of what I need as a reslut (image below)
I tried to use for loops that compare the two vectors of dates (vectors extracted from the columns) but it does not really work...
I tried something like this to identify start date and end date :
'''
a = sort(data$Date_debut)
b = sort(data$Date_fin)
for(i in 1:(length(a)-1)){
for(j in 2:length(a)){
datedeb = a[j-1]
if(b[i]+1 == a[j]){
while(b[i]+1 == a[j] ){
datefin = b[i+1]
i = i+1}
}
}
}
''' datedeb = start date datefin = end date
Thank you for your help, I am open to ideas / ways to deal with this.